Last active
April 20, 2017 22:34
-
-
Save timleland/6494f7223134a705decf21ecf3afac51 to your computer and use it in GitHub Desktop.
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, 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