Joomla TemplatesWeb HostingFree Joomla Templates
Home Blogs Build notification with Snarl

Build notification with Snarl

Recently I found a neat way to get notified whenever a task gets complete. Its done with the help Snarl and a small python program.

 

Build Notification

In my day job I build my project source at least five times a day. Each build takes 5-15 mins approximately. So I usually start the build in ssh session and switch to Windows for other task. But soon after I totally forget about the build and realize about it after a long time. I thought of writing small program which will notify my Windows machine in someway (probably UDP server/client) whenever the build is complete. But then I remember in Mac OS X we have Growl for general purpose notifiation, Linux also got notification-daemon for this. So I googled and found we Snarl does the job in Windows. I installed Snarl and wrote a small python that connects to my Windows machine Snarl's TCP port and send notification messages. Below is the python program

#!/usr/bin/python
import socket
import sys

argc = len(sys.argv)
if argc > 1:
    message = sys.argv[1]

    if argc > 2:
        title = sys.argv[2]
    else:
        title = socket.gethostname()

    if argc > 3:
        timeout = sys.argv[3]
    else:
        timeout = "5"

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(("chesiparama", 9887))
    s.send("type=SNP#?version=1.0#?action=notification#?app=notify#?title=" + title + "#?text=" + message + "#?timeout=" + timeout + "\r\n")
    s.close()
else:
    print "Usage:\nnotify  "

I use the following commandline to send notification whenever the build gets complete

$ (<build command> && notify.py "Build complete") || notify.py "Build failed"

in the above commandline, if the build succeeds then the second part of the AND(&amp;&amp;) will execute and send "Build complete" notifiation. If the build fails then the second part of the OR(||) will execute and sends "Build failed" notification".

In bash we can use semi-colon to chain commands and run them regardless of their exit status.

command1;command2

In Windows the same can be achieved by using single ampercent

command1 & command2

 

Comments

Name *
Email (For verification & Replies)
URL
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment

Last Updated (Saturday, 04 July 2009 15:01)