Intendation; foodoord_oben - right API™
This commit is contained in:
parent
72b2276603
commit
ce451daef1
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim: ts=2 sw=2 et
|
||||
|
||||
import os
|
||||
import stat
|
||||
@ -14,8 +15,9 @@ from ConfigParser import SafeConfigParser
|
||||
parser = SafeConfigParser()
|
||||
parser.read('/etc/foodoord.conf')
|
||||
|
||||
url = parser.get('door_firstlevel', 'status_url')
|
||||
old_api = parser.get('door_firstlevel_old', 'status_url')
|
||||
doorapi = parser.get('doorstatus', 'status_url')
|
||||
consumerkey = parser.get('doorstatus', 'key')
|
||||
consumersecret = parser.get('doorstatus', 'secret')
|
||||
|
||||
|
||||
#Definitions for output
|
||||
@ -33,10 +35,16 @@ RED=1
|
||||
GREEN=2
|
||||
ORANGE=3
|
||||
|
||||
|
||||
def update_api(locked):
|
||||
try:
|
||||
os.system("/usr/bin/curl -XPOST --header 'Content-Type: application/json' --data '{ \"consumer_key\": \"" + consumerkey + "\", \"consumer_secret\": \"" + consumersecret + "\", \"aerie\": " + str(locked).lower() + " }' '" + doorapi + "' ")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
def doorbell(event):
|
||||
if (STATUS):
|
||||
pifacedigital.relays[RELAYS_UNLOCK].toggle()
|
||||
@ -48,8 +56,7 @@ if __name__ == "__main__":
|
||||
global STATUS
|
||||
STATUS = False
|
||||
try:
|
||||
urllib2.urlopen(url+'&door=aerie&locked=1', timeout=2)
|
||||
urllib2.urlopen(old_api+'&status=closed', timeout=2)
|
||||
update_api(True)
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -66,8 +73,7 @@ if __name__ == "__main__":
|
||||
os.remove("/var/run/foodoord.pipe")
|
||||
|
||||
try:
|
||||
urllib2.urlopen(url+'&door=aerie&locked=1', timeout=2)
|
||||
urllib2.urlopen(old_api+'&status=closed', timeout=2)
|
||||
update_api(True)
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -114,8 +120,7 @@ if __name__ == "__main__":
|
||||
STATUS = False
|
||||
|
||||
try:
|
||||
urllib2.urlopen(url+'&door=aerie&locked=1', timeout=2)
|
||||
urllib2.urlopen(old_api+'&status=closed', timeout=2)
|
||||
update_api(True)
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -129,8 +134,7 @@ if __name__ == "__main__":
|
||||
if (STATUS==False):
|
||||
|
||||
try:
|
||||
urllib2.urlopen(url+'&door=aerie&locked=0', timeout=2)
|
||||
urllib2.urlopen(old_api+'&status=open', timeout=2)
|
||||
update_api(False)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#! /usr/bin/python
|
||||
# vim: ts=2 sw=2 et
|
||||
|
||||
import os
|
||||
import stat
|
||||
|
Loading…
Reference in New Issue
Block a user