[python-bugzilla] [PATCH] bugzilla: honor --cookiefile early so "login" follows it

Jan Pokorný jpokorny at redhat.com
Mon Apr 22 15:41:38 UTC 2013


Hello Don and Cole,

On 19/04/13 11:01 -0400, Don Zickus wrote:
> On Thu, Apr 18, 2013 at 08:43:40PM +0200, Jan Pokorný wrote:
>> So far, ~/.bugzillacookies was a cookie holder regardless of what
>> cookiefile was specified together with "login" command.
> 
> This python seems to clever for some of us part-time python programmers.
> Could we simplify it a little bit with something like the attached patch?

This was a shoot from the hip to get the expected behavior.
Admittedly half-way towards code golf, but sometimes less is more.

The new patch looks good modulo missing space after comma that seems
to be discussed already.

> @@ -933,11 +933,8 @@ def main(bzinstance=None):
>          log.info('Using username/password for authentication')
>          bz.login(global_opt.user, global_opt.password)
>      elif not _is_unittest:
> -        if global_opt.cookiefile:
> -            bz.cookiefile = global_opt.cookiefile
> -        cookiefile = bz.cookiefile
> -        if os.path.exists(cookiefile):
> -            log.info('Using cookies in %s for authentication', cookiefile)
> +        if os.path.exists(bz.cookiefile):
> +            log.info('Using cookies in %s for authentication', bz.cookiefile)
>          else:
>              log.info('No authentication info provided.')
>  

Yeah, reassigning value to bz.cookiefile became redundant, good catch.

> I assume all you want to be able to do is correctly choose a different
> cookiefile using --cookiefile, right?

True;  I only wanted to achieve semantics that I read behind the lines
of help text but not present.

If you are interested, I am using it in the little script I wrote to
follow bugs [1].  I know there is one or more GUI to track bugs,
but nothing suitable for terminal (ncursed-like interactive list would
be best, perhaps some day...).


Thanks for proceeding my suggestion, let me know if there is something
more to do about that.


[1] http://fedorapeople.org/cgit/jpokorny/public_git/watch-bz.git/

-- 
Jan


More information about the python-bugzilla mailing list