Add API v2
This commit is contained in:
parent
5724fcad2a
commit
e2e5878630
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
VERSION=3.1.0
|
VERSION=3.2.0
|
||||||
dpkg-deb --root-owner-group -b debian "foodoord_${VERSION}_all.deb"
|
dpkg-deb --root-owner-group -b debian "foodoord_${VERSION}_all.deb"
|
||||||
|
2
debian/DEBIAN/control
vendored
2
debian/DEBIAN/control
vendored
@ -1,5 +1,5 @@
|
|||||||
Package: foodoord
|
Package: foodoord
|
||||||
Version: 3.0.4
|
Version: 3.2.0
|
||||||
Maintainer: Bandie <bandie@chaospott.de>
|
Maintainer: Bandie <bandie@chaospott.de>
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Description: Control the doors of the club, ja!
|
Description: Control the doors of the club, ja!
|
||||||
|
5
debian/etc/foodoord.conf_example
vendored
5
debian/etc/foodoord.conf_example
vendored
@ -2,3 +2,8 @@
|
|||||||
status_url =
|
status_url =
|
||||||
key =
|
key =
|
||||||
secret =
|
secret =
|
||||||
|
|
||||||
|
[doorstatusv2]
|
||||||
|
status_url =
|
||||||
|
key =
|
||||||
|
secret =
|
||||||
|
37
debian/usr/sbin/foodoord_oben
vendored
37
debian/usr/sbin/foodoord_oben
vendored
@ -10,6 +10,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
import pifacedigitalio
|
import pifacedigitalio
|
||||||
|
|
||||||
@ -32,18 +33,46 @@ ORANGE = 3
|
|||||||
parser = ConfigParser()
|
parser = ConfigParser()
|
||||||
parser.read('/etc/foodoord.conf')
|
parser.read('/etc/foodoord.conf')
|
||||||
|
|
||||||
DOORAPI = parser.get('doorstatus', 'status_url')
|
|
||||||
CONSUMERKEY = parser.get('doorstatus', 'key')
|
@dataclass
|
||||||
CONSUMERSECRET = parser.get('doorstatus', 'secret')
|
class API:
|
||||||
|
api_url: str
|
||||||
|
consumer_key: str
|
||||||
|
consumer_secret: str
|
||||||
|
|
||||||
|
|
||||||
|
APIv1 = API(
|
||||||
|
parser.get('doorstatus', 'status_url'),
|
||||||
|
parser.get('doorstatus', 'key'),
|
||||||
|
parser.get('doorstatus', 'secret'),
|
||||||
|
)
|
||||||
|
APIv2 = API(
|
||||||
|
parser.get('doorstatusv2', 'status_url'),
|
||||||
|
parser.get('doorstatusv2', 'key'),
|
||||||
|
parser.get('doorstatusv2', 'secret'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def update_api(locked):
|
def update_api(locked):
|
||||||
try:
|
try:
|
||||||
|
# API v1
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
"/usr/bin/curl", "-XPOST",
|
"/usr/bin/curl", "-XPOST",
|
||||||
"--header", "Content-Type: application/json",
|
"--header", "Content-Type: application/json",
|
||||||
"--data",
|
"--data",
|
||||||
json.dumps({"consumer_key": CONSUMERKEY, "consumer_secret": CONSUMERSECRET, "aerie": locked})
|
json.dumps({"consumer_key": APIv1.consumer_key, "consumer_secret": APIv1.consumer_secret, "aerie": locked}),
|
||||||
|
APIv1.api_url
|
||||||
|
])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
# API v2
|
||||||
|
subprocess.check_call([
|
||||||
|
"/usr/bin/curl", "-XPOST",
|
||||||
|
"--header", "Content-Type: application/json",
|
||||||
|
"--data",
|
||||||
|
json.dumps({"consumer_key": APIv2.consumer_key, "consumer_secret": APIv2.consumer_secret, "aerie": locked}),
|
||||||
|
APIv2.api_url
|
||||||
])
|
])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
38
debian/usr/sbin/foodoord_unten
vendored
38
debian/usr/sbin/foodoord_unten
vendored
@ -8,6 +8,7 @@ import stat
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
import RPi.GPIO as gpio
|
import RPi.GPIO as gpio
|
||||||
|
|
||||||
@ -31,9 +32,24 @@ ORANGE = 3
|
|||||||
parser = ConfigParser()
|
parser = ConfigParser()
|
||||||
parser.read('/etc/foodoord.conf')
|
parser.read('/etc/foodoord.conf')
|
||||||
|
|
||||||
DOORAPI = parser.get('doorstatus', 'status_url')
|
|
||||||
CONSUMERKEY = parser.get('doorstatus', 'key')
|
@dataclass
|
||||||
CONSUMERSECRET = parser.get('doorstatus', 'secret')
|
class API:
|
||||||
|
api_url: str
|
||||||
|
consumer_key: str
|
||||||
|
consumer_secret: str
|
||||||
|
|
||||||
|
|
||||||
|
APIv1 = API(
|
||||||
|
parser.get('doorstatus', 'status_url'),
|
||||||
|
parser.get('doorstatus', 'key'),
|
||||||
|
parser.get('doorstatus', 'secret'),
|
||||||
|
)
|
||||||
|
APIv2 = API(
|
||||||
|
parser.get('doorstatusv2', 'status_url'),
|
||||||
|
parser.get('doorstatusv2', 'key'),
|
||||||
|
parser.get('doorstatusv2', 'secret'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def write_state(state):
|
def write_state(state):
|
||||||
@ -46,12 +62,24 @@ def write_state(state):
|
|||||||
|
|
||||||
def update_api(locked):
|
def update_api(locked):
|
||||||
try:
|
try:
|
||||||
|
# API v1
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
"/usr/bin/curl", "-XPOST",
|
"/usr/bin/curl", "-XPOST",
|
||||||
"--header", "Content-Type: application/json",
|
"--header", "Content-Type: application/json",
|
||||||
"--data",
|
"--data",
|
||||||
json.dumps({"consumer_key": CONSUMERKEY, "consumer_secret": CONSUMERSECRET, "cellar": locked}),
|
json.dumps({"consumer_key": APIv1.consumer_key, "consumer_secret": APIv1.consumer_secret, "cellar": locked}),
|
||||||
DOORAPI
|
APIv1.api_url
|
||||||
|
])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
# API v2
|
||||||
|
subprocess.check_call([
|
||||||
|
"/usr/bin/curl", "-XPOST",
|
||||||
|
"--header", "Content-Type: application/json",
|
||||||
|
"--data",
|
||||||
|
json.dumps({"consumer_key": APIv2.consumer_key, "consumer_secret": APIv2.consumer_secret, "cellar": locked}),
|
||||||
|
APIv2.api_url
|
||||||
])
|
])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user