Change urgency and expiry of build failure messages.
[tpot/bbremote.git] / bbapplet
index 885625b3ab1d6ac6bc2777da1423c990898c659b..d1399d6156a9387c8f7c0170e64239c4568038f9 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()