Created
August 15, 2013 16:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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