changed api client according to specification
bug fixes in VisionDaemon
This commit is contained in:
parent
ce6b06544a
commit
5e46e8068a
6 changed files with 143 additions and 63 deletions
|
@ -1,3 +1,5 @@
|
|||
from typing import Dict, Tuple
|
||||
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
|
@ -19,37 +21,39 @@ class Seeding:
|
|||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_park() -> int:
|
||||
def get_park() -> Tuple[Dict, int]:
|
||||
"""Get a parkingsapce from the api.
|
||||
|
||||
:return: An int between 0 and 3
|
||||
:rtype: int
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
result = json.loads(requests.get(API_URL_GET_PARK).content)["id"]
|
||||
Logging.get_logger().debug(f"Seeding.get_park = {result}")
|
||||
return result
|
||||
res = requests.get(API_URL_GET_PARK)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.get_park = {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
@staticmethod
|
||||
def pay_park() -> bool:
|
||||
def pay_park() -> int:
|
||||
"""Pay for parking.
|
||||
|
||||
:return: True if successful, False if not successful
|
||||
:rtype: bool
|
||||
:return: Status code as returned by the api.
|
||||
:rtype: int
|
||||
"""
|
||||
result = requests.get(API_URL_PAY_PARK).status_code == 200
|
||||
result = requests.get(API_URL_PAY_PARK).status_code
|
||||
Logging.get_logger().debug(f"Seeding.pay_park = {result}")
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def simon_says() -> int:
|
||||
def simon_says() -> Tuple[Dict, int]:
|
||||
"""Get next simon says zone from the api.
|
||||
|
||||
:return: An int between 0 and 3 or -1 after making this request 5 times.
|
||||
:rtype: int
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
result = json.loads(requests.get(API_URL_SIMON_SAYS).content)["id"]
|
||||
Logging.get_logger().debug(f"Seeding.simon_says = {result}")
|
||||
return result
|
||||
res = requests.get(API_URL_SIMON_SAYS)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.simon_says = {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
|
||||
class Position:
|
||||
|
|
|
@ -8,11 +8,13 @@ from LogstashLogging import logstash_logger
|
|||
from threading import Thread
|
||||
import logging
|
||||
|
||||
RUN_CHECK = False
|
||||
try:
|
||||
from Battery import Battery
|
||||
from Buzzer import Buzzer
|
||||
RUN_CHECK = True
|
||||
except Exception as e:
|
||||
logstash_logger.error("unable to import battery or buzzer in daemon")
|
||||
logstash_logger.error(f"unable to import battery or buzzer in daemon -> {str(e)}")
|
||||
|
||||
__run = """raspivid -t 0 -b 5000000 -w 1280 -h 720 -fps 30 -n -o - | gst-launch-1.0 fdsrc ! video/x-h264,width=1280,height=720,framerate=30/1,noise-reduction=1,profile=high,stream-format=byte-stream ! h264parse ! queue ! flvmux streamable=true ! rtmpsink location=\"rtmp://localhost/live/stream\""""
|
||||
|
||||
|
@ -43,12 +45,13 @@ if __name__ == '__main__':
|
|||
|
||||
logstash_logger.info("starting battery checker")
|
||||
battery_checker = None
|
||||
try:
|
||||
battery_checker = threading.Thread(target=check_battery)
|
||||
battery_checker.start()
|
||||
logstash_logger.info("starting battery checker - DONE")
|
||||
except Exception as e:
|
||||
logstash_logger.error(f"could not start battery checker -> {str(e)}")
|
||||
if RUN_CHECK:
|
||||
try:
|
||||
battery_checker = threading.Thread(target=check_battery)
|
||||
battery_checker.start()
|
||||
logstash_logger.info("starting battery checker - DONE")
|
||||
except Exception as e:
|
||||
logstash_logger.error(f"could not start battery checker -> {str(e)}")
|
||||
|
||||
if STREAM_RASPI:
|
||||
logstash_logger.info("starting gstreamer background process")
|
||||
|
@ -59,5 +62,5 @@ if __name__ == '__main__':
|
|||
if battery_checker is not None:
|
||||
battery_checker.join()
|
||||
else:
|
||||
logstash_logger.info("battery checker failed to initialize.. sleeping for a day")
|
||||
logstash_logger.info("battery checker failed to initialize.. sleeping for a day, good night")
|
||||
time.sleep(60*60*24)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
__version__ = "0.0.4-19"
|
||||
__version__ = "0.0.4-20"
|
||||
|
||||
import compLib.LogstashLogging
|
||||
import logging
|
||||
|
|
Reference in a new issue