~parinporecha/gtg/hamster_plugin_minor_fixes

« back to all changes in this revision

Viewing changes to GTG/plugins/bugzilla/bugzilla.py

  • Committer: Izidor Matušov
  • Date: 2013-07-10 21:19:27 UTC
  • mfrom: (1304.2.3 bugzilla-plugin-bugfix)
  • Revision ID: izidor.matusov@gmail.com-20130710211927-3uq9lskajlnn0pnw
Enhancing Bugzilla plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from urlparse import urlparse
22
22
 
23
23
from services import BugzillaServiceFactory
 
24
from services import BugzillaServiceNotExist
24
25
from notification import send_notification
25
26
 
26
27
__all__ = ('pluginBugzilla', )
27
28
 
28
29
bugIdPattern = re.compile('^\d+$')
 
30
bugURLPattern = re.compile('^(https?)://(.+)/show_bug\.cgi\?id=(\d+)$')
29
31
 
30
32
 
31
33
class GetBugInformationTask(threading.Thread):
42
44
 
43
45
    def run(self):
44
46
        bug_url = self.task.get_title()
 
47
 
 
48
        # We only handle bug URL. When task's title is not a bug URL, stop
 
49
        # handling quietly.
 
50
        if bugURLPattern.match(bug_url) is None:
 
51
            return
 
52
 
45
53
        scheme, hostname, queries = self.parseBugUrl(bug_url)
46
54
 
47
55
        bug_id = queries.get('id', None)
51
59
 
52
60
        try:
53
61
            bugzillaService = BugzillaServiceFactory.create(scheme, hostname)
 
62
        except BugzillaServiceNotExist:
 
63
            # Stop quietly when bugzilla cannot be found. Currently, I don't
 
64
            # assume that user enters a wrong hostname or just an unkown
 
65
            # bugzilla service.
 
66
            return
 
67
 
 
68
        try:
54
69
            bug = bugzillaService.getBug(bug_id)
55
70
        except xmlrpclib.Fault, err:
56
71
            code = err.faultCode