Skip to content

Instantly share code, notes, and snippets.

@timleland
Last active April 20, 2017 22:34
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 timleland/6494f7223134a705decf21ecf3afac51 to your computer and use it in GitHub Desktop.
Save timleland/6494f7223134a705decf21ecf3afac51 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import urllib, json, subprocess, time
lastCommandDate = None
url = 'https://spreadsheets.google.com/feeds/list/YOUR_SPREADSHEET_ID/1/public/values?alt=json'
while True:
time.sleep(.5)
response = urllib.urlopen(url)
data = json.loads(response.read())
try:
lastIndex = len(data['feed']['entry']) - 1
currentCommandDate = data['feed']['entry'][lastIndex]['updated']['$t']
if lastCommandDate != currentCommandDate:
lastCommandDate = currentCommandDate
outletCode = data['feed']['entry'][lastIndex]['gsx$outletid']['$t']
subprocess.call(["/var/www/html/rfoutlet/codesend", outletCode])
except KeyError:
print "No commands exist."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment