[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] use python-bugzilla in export-bugzilla.py



Not quite sure where else to send this, so here goes :)

Attached is a patch to use python-bugzilla in export-bugzilla.py using
new methods that I taught it. I can't exactly be sure that the stuff
works, since partner-bugzilla doesn't have the updateperms call, and
the adduser call seems to require more permissions than I seem to have
on partner-bugzilla, but it seems to get there and work as best it can
:)

[jstanley rugrat ~]$ python bztest.py
Bugzilla user: jonstanley gmail com
bugzilla password:
Traceback (most recent call last):
  File "bztest.py", line 9, in <module>
    server.adduser('jonstanley gmail com','Jon Stanley')
  File "/usr/lib/python2.5/site-packages/bugzilla/base.py", line 689, in adduser
    self._adduser(user,name)
  File "/usr/lib/python2.5/site-packages/bugzilla/rhbugzilla.py", line
334, in _adduser
    r = self._proxy.bugzilla.addUser(user, name, self.user)
  File "/usr/lib64/python2.5/xmlrpclib.py", line 1150, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.5/xmlrpclib.py", line 1440, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.5/site-packages/bugzilla/base.py", line 776, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib64/python2.5/xmlrpclib.py", line 1343, in _parse_response
    return u.close()
  File "/usr/lib64/python2.5/xmlrpclib.py", line 790, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 410: 'Login Required'>
diff --git a/scripts/export-bugzilla.py b/scripts/export-bugzilla.py
index 4b6b416..2cfb63e 100755
--- a/scripts/export-bugzilla.py
+++ b/scripts/export-bugzilla.py
@@ -7,6 +7,7 @@ import sys
 import getopt
 import xmlrpclib
 import turbogears
+import bugzilla
 from turbogears import config
 turbogears.update_config(configfile="/etc/export-bugzilla.cfg")
 from turbogears.database import session
@@ -26,7 +27,7 @@ if __name__ == '__main__':
     ourGroup = args[0]
     bzGroup = args[1]
 
-    server = xmlrpclib.Server(BZSERVER)
+    server = bugzilla.Bugzilla(url=BZSERVER, user=BZUSER, password=BZPASS)
     bugzilla_queue = BugzillaQueue.query.join('group').filter_by(
             name=ourGroup)
 
@@ -35,8 +36,7 @@ if __name__ == '__main__':
         if entry.action == 'r':
             # Remove the user's bugzilla group
             try:
-                server.bugzilla.updatePerms(entry.email, 'rem', (bzGroup,),
-                        BZUSER, BZPASS)
+                server.updateperms(entry.email, 'rem', (bzGroup,))
             except xmlrpclib.Fault, e:
                 if e.faultCode == 504:
                     # It's okay, not having this user is equivalent to setting
@@ -48,7 +48,7 @@ if __name__ == '__main__':
         elif entry.action == 'a':
             # Try to create the user
             try:
-                server.bugzilla.addUser(entry.email, entry.person.human_name, BZUSER, BZPASS)
+                server.adduser(entry.email, entry.person.human_name)
             except xmlrpclib.Fault, e:
                 if e.faultCode == 500:
                     # It's okay, we just need to make sure the user has an
@@ -57,8 +57,7 @@ if __name__ == '__main__':
                 else:
                     print entry.email,entry.person.human_name
                     raise
-            server.bugzilla.updatePerms(entry.email, 'add', (bzGroup,),
-                    BZUSER, BZPASS)
+            server.updateperms(entry.email, 'add', (bzGroup,))
         else:
             print 'Unrecognized action code: %s %s %s %s %s' % (entry.action,
                     entry.email, entry.person.human_name, entry.person.username, entry.group.name)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]