jlec        14/05/19 14:34:10

  Added:                pybugz-0.10.1-bugzilla-4.4.1.patch
  Log:
  www-client/pybugz: Add compatibility patch for bugzilla 4.4.1 made by Akinori 
Hattori, #488688
  
  (Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key 
B9D4F231BD1558AB!)

Revision  Changes    Path
1.1                  www-client/pybugz/files/pybugz-0.10.1-bugzilla-4.4.1.patch

file : 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-client/pybugz/files/pybugz-0.10.1-bugzilla-4.4.1.patch?rev=1.1&view=markup
plain: 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-client/pybugz/files/pybugz-0.10.1-bugzilla-4.4.1.patch?rev=1.1&content-type=text/plain

Index: pybugz-0.10.1-bugzilla-4.4.1.patch
===================================================================
--- a/bugz/cli.py
+++ b/bugz/cli.py
@@ -29,6 +29,7 @@ BUGZ: ---------------------------------------------------
 """
 
 DEFAULT_COOKIE_FILE = '.bugz_cookie'
+DEFAULT_TOKEN_FILE = '.bugz_token'
 DEFAULT_NUM_COLS = 80
 
 #
@@ -143,6 +144,12 @@ class PrettyBugz:
                except IOError:
                        pass
 
+               self.token_file = os.path.join(os.environ['HOME'], 
DEFAULT_TOKEN_FILE)
+               try:
+                       self.token = open(self.token_file).read().strip()
+               except IOError:
+                       self.token = None
+
                if getattr(args, 'encoding'):
                        self.enc = args.encoding
                else:
@@ -170,16 +177,21 @@ class PrettyBugz:
        def get_input(self, prompt):
                return raw_input(prompt)
 
+       def set_token(self, *args):
+               if args and self.token:
+                       args[0]['token'] = self.token
+               return args
+
        def bzcall(self, method, *args):
                """Attempt to call method with args. Log in if authentication 
is required.
                """
                try:
-                       return method(*args)
+                       return method(*self.set_token(*args))
                except xmlrpclib.Fault, fault:
                        # Fault code 410 means login required
                        if fault.faultCode == 410 and not self.skip_auth:
                                self.login()
-                               return method(*args)
+                               return method(*self.set_token(*args))
                        raise
 
        def login(self, args=None):
@@ -207,11 +219,20 @@ class PrettyBugz:
                if args is not None:
                        params['remember'] = True
                self.log('Logging in')
-               self.bz.User.login(params)
+               result = self.bz.User.login(params)
+               if 'token' in result:
+                       self.token = result['token']
 
                if args is not None:
-                       self.cookiejar.save()
-                       os.chmod(self.cookiejar.filename, 0600)
+                       if self.token:
+                               fd = open(self.token_file, 'w')
+                               fd.write(self.token)
+                               fd.write('\n')
+                               fd.close()
+                               os.chmod(self.token_file, 0600)
+                       else:
+                               self.cookiejar.save()
+                               os.chmod(self.cookiejar.filename, 0600)
 
        def logout(self, args):
                self.log('logging out')




Reply via email to