#!/usr/bin/python import pygtk pygtk.require('2.0') from twisted.internet import gtk2reactor gtk2reactor.install() from twisted.internet import reactor from twisted.spread import pb import sys, gtk, gnomeapplet, pynotify from bbclient import BuildbotClient HOST = 'localhost' PORT = 1234 USER = 'statusClient' PASS = 'clientpw' class BuildbotApplet(pb.Referenceable): def __init__(self, applet, icon): self.applet = applet self.applet.add(icon) self.applet.show_all() client = BuildbotClient() d = client.connect(HOST, PORT, USER, PASS) d.addCallback(lambda arg: client.subscribe('builds', 5, self)) # Callbacks for subscription mode >= MODE_BUILDERS def remote_builderAdded(self, buildername, builder): pass def remote_builderRemoved(self, buildername): pass def remote_builderChangedState(self, buildername, statename, eta): pass # Callbacks for subscription mode >= MODE_BUILDS def remote_buildStarted(self, buildername, build): n = pynotify.Notification('Build started', buildername) n.set_urgency(pynotify.URGENCY_LOW) n.set_category('eep') n.attach_to_widget(self.applet) n.show() def remote_buildFinished(self, buildername, build, result): n = pynotify.Notification('Build finished', buildername) n.set_urgency(pynotify.URGENCY_LOW) n.set_category('eep') n.attach_to_widget(self.applet) n.show() def BuildbotApplet_factory(applet, iid): pynotify.init("bbapplet") icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU) BuildbotApplet(applet, icon) return gtk.TRUE if __name__ == "__main__": if len(sys.argv) == 2 and sys.argv[1] == "run-in-window": # Run in a window, for debugging main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("buildbot applet") main_window.connect('destroy', gtk.main_quit) app = gnomeapplet.Applet() BuildbotApplet_factory(app, None) app.reparent(main_window) main_window.show_all() reactor.run() else: # Run as bonobo component reactor.startRunning() reactor.simulate() gnome.applet.bonobo_factory("OAFIID:GNOME_BuildbotApplet_Factory", gnome.applet.Applet.__gtype__, "bbapplet", "0", BuildbotApplet_factory)