added api requests
This commit is contained in:
parent
bb4483b141
commit
d06e6fa32d
4 changed files with 55 additions and 25 deletions
|
@ -34,7 +34,7 @@ fpm -s python --python-bin python3 --python-pip pip3 --python-package-name-prefi
|
|||
-d "python3-pigpio" \
|
||||
-d "python3-numpy" \
|
||||
-d "ffmpeg" \
|
||||
-v 0.2.1-0 -t deb setup.py
|
||||
-v 0.2.2-0 -t deb setup.py
|
||||
|
||||
# --deb-changelog changelog \
|
||||
# --deb-upstream-changelog changelog \
|
||||
|
|
|
@ -8,14 +8,18 @@ import time
|
|||
from compLib.LogstashLogging import Logging
|
||||
|
||||
API_URL = os.getenv("API_URL", "http://localhost:5000/") + "api/"
|
||||
API_URL_GET_DELIVERY = API_URL + "getDelivery"
|
||||
API_URL_GET_MATERIAL = API_URL + "getMaterial"
|
||||
API_URL_GET_GARBAGE = API_URL + "getGarbage"
|
||||
API_URL_GET_LIST_CARGO = API_URL + "listCargo"
|
||||
API_URL_GET_CARGO = API_URL + "getCargo/"
|
||||
|
||||
API_URL_GET_POS = API_URL + "getPos"
|
||||
API_URL_GET_OP = API_URL + "getOp"
|
||||
API_URL_GET_GOAL = API_URL + "getGoal"
|
||||
API_URL_GET_ITEMS = API_URL + "getItems"
|
||||
API_URL_GET_PARK = API_URL + "getPark"
|
||||
API_URL_PAY_PARK = API_URL + "payPark"
|
||||
API_URL_SIMON_SAYS = API_URL + "simonSays"
|
||||
API_URL_GET_SCORES = API_URL + "getScores"
|
||||
API_URL_GET_METEOROID = API_URL + "getMeteoroid"
|
||||
|
||||
|
||||
class Seeding:
|
||||
|
@ -23,38 +27,64 @@ class Seeding:
|
|||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_park() -> Tuple[Dict, int]:
|
||||
"""Get a parkingsapce from the api.
|
||||
def get_delivery() -> Tuple[Dict, int]:
|
||||
"""Makes the /api/getDelivery call to the api.
|
||||
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_PARK)
|
||||
res = requests.get(API_URL_GET_DELIVERY)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.get_park = {result}, status code = {res.status_code}")
|
||||
Logging.get_logger().debug(f"Seeding.get_delivery = {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
@staticmethod
|
||||
def pay_park() -> int:
|
||||
"""Pay for parking.
|
||||
|
||||
:return: Status code as returned by the api.
|
||||
:rtype: int
|
||||
"""
|
||||
result = requests.get(API_URL_PAY_PARK).status_code
|
||||
Logging.get_logger().debug(f"Seeding.pay_park = {result}")
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def simon_says() -> Tuple[Dict, int]:
|
||||
"""Get next simon says zone from the api.
|
||||
def get_material() -> Tuple[Dict, int]:
|
||||
"""Makes the /api/getMaterial call to the api.
|
||||
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
res = requests.get(API_URL_SIMON_SAYS)
|
||||
res = requests.get(API_URL_GET_MATERIAL)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.simon_says = {result}, status code = {res.status_code}")
|
||||
Logging.get_logger().debug(f"Seeding.get_material = {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
@staticmethod
|
||||
def get_garbage() -> Tuple[Dict, int]:
|
||||
"""Makes the /api/getGarbage call to the api.
|
||||
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_GARBAGE)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.get_garbage {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
@staticmethod
|
||||
def list_cargo() -> Tuple[Dict, int]:
|
||||
"""Makes the /api/listCargo call to the api.
|
||||
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_LIST_CARGO)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.list_cargo {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
@staticmethod
|
||||
def getCargo(color: str) -> Tuple[Dict, int]:
|
||||
"""Makes the /api/listCargo call to the api.
|
||||
|
||||
:param color: Color parameter which specifies which cargo should be taken. (A string which is either "green", "red", "yellow" or "blue"
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_CARGO + color)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.get_cargo {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
__version__ = "0.2.1-0"
|
||||
__version__ = "0.2.2-0"
|
||||
|
||||
import importlib
|
||||
import compLib.LogstashLogging
|
||||
|
|
2
setup.py
2
setup.py
|
@ -12,7 +12,7 @@ else:
|
|||
|
||||
setuptools.setup(
|
||||
name="complib",
|
||||
version="0.2.1-0",
|
||||
version="0.2.2-0",
|
||||
author="F-WuTs",
|
||||
author_email="--",
|
||||
description="",
|
||||
|
|
Reference in a new issue