Skip to content

Instantly share code, notes, and snippets.

@potch
Created December 30, 2010 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save potch/760282 to your computer and use it in GitHub Desktop.
Save potch/760282 to your computer and use it in GitHub Desktop.
Hudson Checker with growl notification
#!/usr/bin/env python
from pyquery import PyQuery as pq
import re
import os
import time
HUDSON_URL = 'https://hudson.mozilla.org/job/amo-master/lastBuild/'
old_status = ''
while True:
doc = pq(url=HUDSON_URL)
h1 = doc('h1').html()
build_num = re.search('Build \#([0-9,]+)', h1).group(1)
build_status = doc('h1').find('img').attr('tooltip')
if build_status == "In progress":
build_progress = doc('h1').find('.progress-bar-done').attr('style')
build_progress = re.search('[0-9]+\%', build_progress).group()
os.system('growlnotify -m "Build %d: %s (%s)" Hudson' %
(int(build_num), build_status, build_progress))
time.sleep(60)
else:
if build_status != old_status:
os.system('growlnotify -m "Build %d: %s" Hudson' %
(int(build_num), build_status))
time.sleep(300)
old_status = build_status
@potch
Copy link
Author

potch commented Jan 13, 2011

Tongue-in-cheek backgrounding instructions:
% ./hud.py&

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment