updated setup.py
added api.py and implemented double elimination api
This commit is contained in:
parent
5942c13721
commit
609ce3478f
2 changed files with 58 additions and 2 deletions
51
compLIB/Api.py
Normal file
51
compLIB/Api.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
import requests
|
||||
import json
|
||||
import os
|
||||
|
||||
API_URL = os.getenv("API_URL", "http://localhost:5000/")
|
||||
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"
|
||||
|
||||
|
||||
class Seeding:
|
||||
@staticmethod
|
||||
def get_park():
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def pay_park():
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def simon_says():
|
||||
pass
|
||||
|
||||
|
||||
class Position:
|
||||
def __init__(self, x, y, rotation):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.rotation = rotation
|
||||
|
||||
|
||||
class DoubleElim:
|
||||
@staticmethod
|
||||
def get_position():
|
||||
response = json.loads(requests.get(API_URL_GET_POS).content)
|
||||
return Position(response["x"], response["y"], response["degrees"])
|
||||
|
||||
@staticmethod
|
||||
def get_opponent():
|
||||
response = json.loads(requests.get(API_URL_GET_OP).content)
|
||||
return Position(response["x"], response["y"], response["degrees"])
|
||||
|
||||
@staticmethod
|
||||
def get_goal():
|
||||
response = json.loads(requests.get(API_URL_GET_GOAL).content)
|
||||
return Position(response["x"], response["y"], -1)
|
||||
|
||||
@staticmethod
|
||||
def get_items():
|
||||
return json.loads(requests.get(API_URL_GET_ITEMS).content)
|
9
setup.py
9
setup.py
|
@ -28,6 +28,11 @@ setuptools.setup(
|
|||
],
|
||||
license="proprietary",
|
||||
install_requires=[
|
||||
"smbus",
|
||||
]
|
||||
"smbus",
|
||||
"requests"
|
||||
],
|
||||
setup_requires=[
|
||||
"smbus",
|
||||
"requests"
|
||||
],
|
||||
)
|
||||
|
|
Reference in a new issue