Skip to content

Instantly share code, notes, and snippets.

@Luzifer
Created August 15, 2013 16:58
Show Gist options
  • Save Luzifer/6242492 to your computer and use it in GitHub Desktop.
Save Luzifer/6242492 to your computer and use it in GitHub Desktop.
Script to output last 5 status messages from status.gitub.com to be used for example with GeekTool or similar
#!/usr/bin/env python
import urllib, json
from dateutil.parser import parse
from textwrap import wrap
messages_url = 'https://status.github.com/api/messages.json'
data = json.loads(urllib.urlopen(messages_url).read())
status_char = {
'good' : '+'
, 'minor' : 'o'
, 'major' : '-'
}
for message in data[0:5]:
date = parse(message['created_on'])
prefix = '[%s][%s] ' % (date.strftime('%Y-%m-%d %H:%M %Z'), status_char[message['status']])
w = '\n%s' % (' ' * len(prefix))
msg = w.join(wrap(message['body'], 60))
print '%s%s' % (prefix, msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment