On 04/22/2013 11:56 AM, Don Zickus wrote:
When using the option --cookiefile for bugzilla, the cookiefile
override happens to late. Use the passed in file during the
beginning of init.
This is addressed by defaulting the cookiefile to None to simplify
the passed in argument code. Then the Bugzilla init routine assigns
the default of ~/.bugzillacookies if cookiefile is None.
This shouldn't affect any of the other scripts that do not use the
cookiefile as an arg.
Reported-by: Jan Pokorný <jpokorny(a)redhat.com>
Signed-off-by: Don Zickus <dzickus(a)redhat.com>
---
bin/bugzilla | 11 ++++-------
bugzilla/base.py | 5 +++--
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/bin/bugzilla b/bin/bugzilla
index cd518c0..d6ba8cf 100755
--- a/bin/bugzilla
+++ b/bin/bugzilla
@@ -94,7 +94,7 @@ def setup_parser():
help="username")
p.add_option('--password',
help="password")
- p.add_option('--cookiefile',
+ p.add_option('--cookiefile', default=None,
help="cookie file to use for bugzilla authentication")
p.add_option('--verbose', action='store_true',
help="give more info about what's going on")
@@ -900,7 +900,7 @@ def main(bzinstance=None):
if bzinstance:
bz = bzinstance
else:
- bz = bzclass(url=global_opt.bugzilla)
+ bz = bzclass(url=global_opt.bugzilla, cookiefile=global_opt.cookiefile)
# Handle 'login' action
@@ -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.')
diff --git a/bugzilla/base.py b/bugzilla/base.py
index c2b9295..658fcc7 100644
--- a/bugzilla/base.py
+++ b/bugzilla/base.py
@@ -187,13 +187,14 @@ class BugzillaBase(object):
url = url + '/xmlrpc.cgi'
return url
- def __init__(self, url=None, user=None, password=None,
- cookiefile=os.path.expanduser('~/.bugzillacookies')):
+ def __init__(self, url=None, user=None, password=None, cookiefile=None):
# Settings the user might want to tweak
self.user = user or ''
self.password = password or ''
self.url = ''
+ if not cookiefile:
+ cookiefile = os.path.expanduser('~/.bugzillacookies')
self._cookiefobj = None
self._cookiejar = None
self._cookiefile = -1
ACK, pushed now.
Thanks,
Cole