← Back to team overview

gtg team mailing list archive

[Merge] lp:~qcxhome/gtg/bugzilla_plugin_devel into lp:gtg

 

Chenxiong Qi has proposed merging lp:~qcxhome/gtg/bugzilla_plugin_devel into lp:gtg.

Requested reviews:
  Gtg developers (gtg)

For more details, see:
https://code.launchpad.net/~qcxhome/gtg/bugzilla_plugin_devel/+merge/141632
-- 
https://code.launchpad.net/~qcxhome/gtg/bugzilla_plugin_devel/+merge/141632
Your team Gtg developers is requested to review the proposed merge of lp:~qcxhome/gtg/bugzilla_plugin_devel into lp:gtg.
=== modified file 'GTG/plugins/bugzilla/bug.py'
--- GTG/plugins/bugzilla/bug.py	2012-07-13 17:24:28 +0000
+++ GTG/plugins/bugzilla/bug.py	2013-01-02 16:22:24 +0000
@@ -27,35 +27,26 @@
     def __init__(self, base, nb):
         #this also handles old versions of pybugz
         try:
-            self.bug = bugzilla.Bugz(base, skip_auth=True).get(nb)
+            bugs = bugzilla.BugzillaProxy(base, skip_auth=True).Bug.get({ 'ids': [nb,], })
         except:
-            self.bug = bugzilla.Bugz(base).get(nb)
-        if self.bug is None:
-            raise Exception('Failed to create bug')
-
-    def _get_detail(self, detail):
-        tmp = self.bug.find('//%s' % detail)
-        if tmp is None:
-            return None
-
-        return tmp.text
+            bugs = bugzilla.BugzillaProxy(base).Bug.get({ 'ids': [nb,], })
+        self.bug = bugs['bugs'][0]
 
     def get_title(self):
-        return self._get_detail('short_desc')
+        return self.bug['summary']
 
     def get_product(self):
-        return self._get_detail('product')
+        return self.bug['product']
 
     def get_component(self):
-        return self._get_detail('component')
+        return self.bug['component']
 
     def get_description(self):
-        comment = self.bug.findall('//long_desc')[0]
-        return comment.find('.//thetext').text
+        return self.bug['summary']
 
 if __name__ == '__main__':
-    for bug in [Bug('http://bugzilla.gnome.org', '598354'),
-            Bug('http://bugs.freedesktop.org', '24120')]:
+    for bug in [Bug('https://bugzilla.gnome.org', '598354'),
+            Bug('https://bugs.freedesktop.org', '24120')]:
         print "title:", bug.get_title()
         print "product:", bug.get_product()
         print "component:", bug.get_component()

=== modified file 'GTG/plugins/bugzilla/bugzilla.py'
--- GTG/plugins/bugzilla/bugzilla.py	2012-07-13 17:24:28 +0000
+++ GTG/plugins/bugzilla/bugzilla.py	2013-01-02 16:22:24 +0000
@@ -16,6 +16,7 @@
 
 import gobject
 import threading
+import xmlrpclib
 from urlparse import urlparse
 
 from GTG.plugins.bugzilla.server import ServersStore
@@ -52,7 +53,7 @@
         if server is None:
             return
 
-        base = '%s://%s' % (r.scheme, server.name)
+        base = '%s://%s/xmlrpc.cgi' % (r.scheme, server.name)
 
         # get the number of the bug
         try:
@@ -62,6 +63,20 @@
 
         try:
             bug = Bug(base, nb)
+        except xmlrpclib.Fault, err:
+            code = err.faultCode
+            if code == 100: # invalid bug ID
+                title = 'Invalid bug ID #%s' % nb
+            elif code == 101: # bug ID not exist
+                title = 'Bug #%s does not exist.' % nb
+            elif code == 102: # Access denied
+                title = 'Access denied to bug #%s' % nb
+            else: # unrecoganized error code currently
+                title = err.faultString
+            old_title = task.get_title()
+            gobject.idle_add(task.set_title, title)
+            gobject.idle_add(task.set_text, old_title)
+            return
         except:
             return