[libvirt] [jenkins-ci PATCH v2 03/20] quayadmin: Tweak quiet logic

Daniel P. Berrangé berrange at redhat.com
Wed Jul 17 17:14:32 UTC 2019


On Wed, Jul 17, 2019 at 03:49:12PM +0200, Andrea Bolognani wrote:
> If we've been asked not to produce any output, we can bail
> early: doing so means we don't need to increase indentation
> for subsequent code, and in some cases we can even avoid
> fetching the JSON data from the response object.

Unless I'm mis-reading the last point doesn't seem to affect
this patch - we're still fetching JSON, which is good I think,
as it means we check the response is well formed, and not an
error of some kind

> 
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
>  guests/quayadmin | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>

> 
> diff --git a/guests/quayadmin b/guests/quayadmin
> index 5dc5eff..3e6cc87 100755
> --- a/guests/quayadmin
> +++ b/guests/quayadmin
> @@ -83,9 +83,12 @@ def run_show_repo(args):
>                   .format(args.namespace, args.repo)):
>          return 1
>  
> +    if args.quiet:
> +        return 0
> +
>      info = res.json()
> -    if not args.quiet:
> -        print("{}/{}: {}".format(args.namespace, args.repo, info["description"]))
> +
> +    print("{}/{}: {}".format(args.namespace, args.repo, info["description"]))
>  
>  
>  def run_create_repo(args):
> @@ -101,8 +104,10 @@ def run_create_repo(args):
>                   .format(args.namespace, args.repo)):
>          return 1
>  
> -    if not args.quiet:
> -        print("Repository {}/{} created".format(args.namespace, args.repo))
> +    if args.quiet:
> +        return 0
> +
> +    print("Repository {}/{} created".format(args.namespace, args.repo))
>  
>  
>  def run_delete_repo(args):
> @@ -112,8 +117,10 @@ def run_delete_repo(args):
>                   .format(args.namespace, args.repo)):
>          return 1
>  
> -    if not args.quiet:
> -        print("Repository {}/{} deleted".format(args.namespace, args.repo))
> +    if args.quiet:
> +        return 0
> +
> +    print("Repository {}/{} deleted".format(args.namespace, args.repo))
>  
>  
>  def add_arg_namespace(parser):
> -- 
> 2.21.0
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list