diff options
author | Will Woods <wwoods@redhat.com> | 2008-06-06 13:23:23 -0400 |
---|---|---|
committer | Will Woods <wwoods@redhat.com> | 2008-06-06 13:23:23 -0400 |
commit | 1805ac8a6645c3d9ee191e597320d7792f6b91f8 (patch) | |
tree | 15b5ff4d3a911d1593e9bbcec403eadb5e37dfc9 | |
parent | 1cc470aa2d6bd55b31cbecc71c48f0b589013fd5 (diff) | |
download | python-bugzilla-1805ac8a6645c3d9ee191e597320d7792f6b91f8.tar.gz python-bugzilla-1805ac8a6645c3d9ee191e597320d7792f6b91f8.tar.xz python-bugzilla-1805ac8a6645c3d9ee191e597320d7792f6b91f8.zip |
remove broken cookiefile junk, add more debugging
-rwxr-xr-x | bin/bugzilla | 27 | ||||
-rw-r--r-- | bugzilla/base.py | 20 |
2 files changed, 12 insertions, 35 deletions
diff --git a/bin/bugzilla b/bin/bugzilla index 060820b..7643c31 100755 --- a/bin/bugzilla +++ b/bin/bugzilla @@ -25,17 +25,6 @@ if '--debug' in sys.argv: elif '--verbose' in sys.argv: log.setLevel(logging.INFO) -def findcookie(): - globs = ['~/.mozilla/firefox/*default*/cookies.txt'] - for g in globs: - log.debug("Looking for cookies.txt in %s", g) - cookiefiles = glob.glob(os.path.expanduser(g)) - if cookiefiles: - # return the first one we find. - # TODO: find all cookiefiles, sort by age, use newest - return cookiefiles[0] -cookiefile = None - cmdlist = ('info','query','new','modify') def setup_parser(): u = "usage: %prog [global options] COMMAND [options]" @@ -46,11 +35,9 @@ def setup_parser(): p.add_option('--bugzilla',default=default_bz, help="bugzilla XMLRPC URI. default: %s" % default_bz) p.add_option('--user', - help="username. Will attempt to use browser cookie if not specified.") + help="username") p.add_option('--password', - help="password. Will attempt to use browser cookie if not specified.") - p.add_option('--cookiefile', - help="cookie file to use for bugzilla authentication") + help="password") p.add_option('--verbose',action='store_true', help="give more info about what's going on") p.add_option('--debug',action='store_true', @@ -205,16 +192,8 @@ if __name__ == '__main__': if global_opt.user and global_opt.password: log.info('Using username/password for authentication') bz.login(global_opt.user,global_opt.password) - elif global_opt.cookiefile: - log.info('Using cookies in %s for authentication', global_opt.cookiefile) - bz.readcookiefile(global_opt.cookiefile) else: - cookiefile = findcookie() - if cookiefile: - log.info('Using cookies in %s for authentication', cookiefile) - bz.readcookiefile(cookiefile) - else: - parser.error("Could not find a Firefox cookie file. Try --user/--password.") + log.info('No authentication info found.') # And now we actually execute the given command buglist = list() # save the results of query/new/modify here diff --git a/bugzilla/base.py b/bugzilla/base.py index 1aa2e89..f00bc86 100644 --- a/bugzilla/base.py +++ b/bugzilla/base.py @@ -72,8 +72,6 @@ class BugzillaBase(object): self._bugfields = None self._components = dict() self._components_details = dict() - if 'cookies' in kwargs: - self.readcookiefile(kwargs['cookies']) if 'url' in kwargs: self.connect(kwargs['url']) if 'user' in kwargs: @@ -83,14 +81,6 @@ class BugzillaBase(object): #---- Methods for establishing bugzilla connection and logging in - def readcookiefile(self,cookiefile): - '''Read the given (Mozilla-style) cookie file and fill in the cookiejar, - allowing us to use the user's saved credentials to access bugzilla.''' - cj = cookielib.MozillaCookieJar() - cj.load(cookiefile) - self._cookiejar = cj - self._cookiejar.filename = cookiefile - def connect(self,url): '''Connect to the bugzilla instance with the given url.''' # Set up the transport @@ -328,6 +318,7 @@ class BugzillaBase(object): def getbug(self,id): '''Return a Bug object with the full complement of bug data already loaded.''' + log.debug("getbug(%i)" % id) return Bug(bugzilla=self,dict=self._getbug(id)) def getbugsimple(self,id): '''Return a Bug object given bug id, populated with simple info''' @@ -645,6 +636,8 @@ class CookieTransport(xmlrpclib.Transport): # ...and put them over the connection for h,v in cookielist: connection.putheader(h,v) + else: + log.debug("send_cookies(): cookiejar empty. Nothing to send.") # This is the same request() method from xmlrpclib.Transport, # with a couple additions noted below @@ -712,14 +705,19 @@ class Bug(object): self.bugzilla = bugzilla self.autorefresh = True if 'dict' in kwargs and kwargs['dict']: + log.debug("Bug(%s)" % kwargs['dict'].keys()) self.__dict__.update(kwargs['dict']) if 'bug_id' in kwargs: + log.debug("Bug(%i)" % kwargs['bug_id']) setattr(self,'bug_id',kwargs['bug_id']) if 'autorefresh' in kwargs: self.autorefresh = kwargs['autorefresh'] # No bug_id? this bug is invalid! if not hasattr(self,'bug_id'): - raise TypeError, "Bug object needs a bug_id" + if hasattr(self,'id'): + self.bug_id = self.id + else: + raise TypeError, "Bug object needs a bug_id" self.url = bugzilla.url.replace('xmlrpc.cgi', 'show_bug.cgi?id=%i' % self.bug_id) |