Change urgency and expiry of build failure messages.
authorTim Potter <tpot@hp.com>
Thu, 10 Apr 2008 05:47:30 +0000 (15:47 +1000)
committerTim Potter <tpot@hp.com>
Thu, 10 Apr 2008 05:47:30 +0000 (15:47 +1000)
Also add a funky red exclamation mark image when the build fails.

applet-critical.png [new file with mode: 0644]
bbapplet

diff --git a/applet-critical.png b/applet-critical.png
new file mode 100644 (file)
index 0000000..4938074
Binary files /dev/null and b/applet-critical.png differ
index 885625b..d1399d6 100755 (executable)
--- a/bbapplet
+++ b/bbapplet
@@ -9,7 +9,7 @@ gtk2reactor.install()
 from twisted.internet import reactor
 from twisted.spread import pb
 
-import sys, gtk, gnomeapplet, pynotify
+import sys, os, gtk, gnomeapplet, pynotify
 from bbclient import BuildbotClient, CommandLineOptions
 
 class BuildbotApplet(pb.Referenceable):
@@ -52,10 +52,24 @@ class BuildbotApplet(pb.Referenceable):
 
     def remote_buildFinished(self, buildername, build, result):
 
-        n = pynotify.Notification('Build finished', buildername)
+        urgency = pynotify.URGENCY_LOW
+        message = 'Build succeeded'
+        expiry = pynotify.EXPIRES_DEFAULT
+        image = None
+
+        if result > 0:
+
+            urgency = pynotify.URGENCY_CRITICAL
+            message = 'Build failed!'
+            expiry = pynotify.EXPIRES_NEVER
+            image = 'file://' + os.path.abspath(os.path.curdir) + \
+                '/applet-critical.png'
+            
+        n = pynotify.Notification(message, buildername, image)
+
+        n.set_urgency(urgency)
+        n.set_timeout(expiry)
 
-        n.set_urgency(pynotify.URGENCY_LOW)
-        n.set_category('eep')
         n.attach_to_widget(self.applet)
         n.show()