# Bugzilla Lookup: a GNOME Deskbar plugin # find and open bugs by ID from your favorite Bugzilla database # Copyright (C) 2006 Mark Pilgrim # # To install, copy to ~/.gnome2/deskbar-applet/handlers/ # right-click Deskbar, select Preferences, and check # "Bugzilla lookup". # # To use, type "bug " followed by the ID of the bug, FOLLOWED BY # A PERIOD ("."). To reduce network traffic and server load, # Bugzilla Lookup will only fetch bug info once you type the # period. # # By default the plugin will search Mozilla's bug database. # You can customize the BUGZILLA_URL below to point to a different # Bugzilla database. # # Example: typing "bug 304497." displays "Show Bug 304497 - RSS not accessible" # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You can download a copy of the GNU General Public License at # http://diveintomark.org/projects/deskbar/COPYING # or get a free printed copy by writing to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from gettext import gettext as _ import gnomevfs from deskbar.Handler import Handler from deskbar.Match import Match import gtk, gtk.gdk import re, urllib # Customize this to point to your favorite Bugzilla database. # The bug ID will be appended to this URL. BUGZILLA_URL = "https://bugzilla.mozilla.org/show_bug.cgi?id=" HANDLERS = { "BugzillaHandler" : { "name": _("Bugzilla Lookup"), "description": _("Look up bugs in a Bugzilla database"), } } BUGZILLA_CACHE = {} class BugzillaMatch(Match): def __init__(self, backend, url=None, **args): Match.__init__(self, backend, **args) self.url = url def action(self, text=None): gnomevfs.url_show(self.url) def get_category(self): return "web" def get_verb(self): return _("Show %(name)s") def get_hash(self, text=None): return self.url class BugzillaHandler(Handler): def __init__(self): Handler.__init__(self, "gnome-mime-application-x-python.png") def initialize(self): pass def idToTitle(self, id): usock = urllib.urlopen(BUGZILLA_URL + id) data = usock.read(512) usock.close() if data.find('