Skip to content

Instantly share code, notes, and snippets.

@jonalmeida
Created July 24, 2015 18:11
Show Gist options
  • Save jonalmeida/4da11c580237fb33d63e to your computer and use it in GitHub Desktop.
Save jonalmeida/4da11c580237fb33d63e to your computer and use it in GitHub Desktop.
Notifies you when your try build is complete.

Why

Instead of checking when your try build is complete, this short python script checks try every 5 mins (you can change the interval if you like) using the treeherder API to see if your try push is complete. Gives you a simple notification in your Notification Center (on Mac OS).

How To Use

  • chmod +x try_to_notify
  • (Optional) Move to your /usr/local/bin and remove .py extension
  • try_to_notify [sha_of_the_try_push]

Examples

  • try_to_notify af6c9cb5e751 (See the try push here)

Dependencies

  • Treeherder python API and a python wrapper for Mac OS's Notification Center
    • pip install treeherder-client pync
#!/usr/bin/env python
from thclient import TreeherderClient
from pync import Notifier
import schedule, time
import getopt, sys
# Treeherder client API
client = TreeherderClient(protocol='https', host='treeherder.mozilla.org')
# Revision
output=None
def job():
completed = False
resultsets = client.get_resultsets('try', revision=output)
for resultset in resultsets:
jobs = client.get_jobs('try', result_set_id=resultset['id'])
for job in jobs:
if job['state'] == 'completed':
completed = True
else:
completed = False
#print job
if completed == True:
Notifier.notify('Build & tests complete', title='Try', sound='Glass')
print 'Try done!'
sys.exit()
else:
print 'Nope!'
def main():
global output
output=sys.argv[1]
job()
#sys.exit()
while True:
schedule.run_pending()
time.sleep(1)
#print output
schedule.every(5).minutes.do(job)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment