Skip to content

Instantly share code, notes, and snippets.

@lightx
Created February 11, 2014 19:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lightx/8942117 to your computer and use it in GitHub Desktop.
Save lightx/8942117 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import requests
import json
import time
import calendar
import subprocess
last_time = 0
while True:
r = requests.get('http://api.thingm.com/blink1/events/0123456701234567')
data = r.content
ev = json.loads(data)
if ev['event_count'] > 0:
print 'events to process'
for e in ev['events']:
print e
if int(e['date']) > last_time:
print 'trigger: ' + e['name']
subprocess.call(['./'+e['name']+'.sh'])
last_time = calendar.timegm(time.gmtime())
time.sleep(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment