added more api documentation

new build process
This commit is contained in:
Joel 2021-01-16 23:33:09 +01:00
parent 73284ceab8
commit 134cd3a30e
No known key found for this signature in database
GPG key ID: BDDDBECD0808290E
7 changed files with 53 additions and 70 deletions

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
python3 setup.py sdist
cd dist || exit
tar -xzmf *.tar.gz
cd complib-0.0.1 || exit
debmake -b":python3"
gbp buildpackage --git-sign-tags --git-keyid=97B61E4D515353C0A498D2AB22680B5AAC0C4FCE --git-ignore-new # git ignore while developing

8
build_deb.sh Normal file
View file

@ -0,0 +1,8 @@
#!/usr/bin/zsh
# be sure to change version if needed!
fpm -s python --python-bin python3 --python-pip pip3 --python-package-name-prefix python3 \
-m '"Joel Klimont" <joel.klimont@gmail.com>' \
--license 'proprietary' \
--description 'Library for robot used in the competition' \
--after-install postinstall.sh \
-v 0.0.2 -t deb setup.py

View file

@ -1,23 +0,0 @@
#!/usr/bin/env bash
# use this to create a new version, be sure to push the existing /debian folder from the old one
new_version="0.0.2"
python3 setup.py sdist
cd dist || exit
mkdir build_${new_version}
mv *-${new_version}.tar.gz build_${new_version}
cd build_${new_version} || exit
tar -xzmf *-${new_version}.tar.gz
new_version="complib-${new_version}"
cd ${new_version} || exit
if [ -d "debian" ]; then
echo "Found debian folder"
else
echo "Could not find debian folder, cloning repo"
git clone https://github.com/F-WuTS/complib-DEB.git
mv complib-DEB debian
git init
fi
#debmake -b":python3"
#gbp buildpackage --git-sign-tags --git-keyid=97B61E4D515353C0A498D2AB22680B5AAC0C4FCE --git-ignore-new # git ignore while developing

View file

@ -15,14 +15,23 @@ API_URL_SIMON_SAYS = API_URL + "simonSays"
class Seeding:
@staticmethod
def get_park() -> int:
"""Get a parkingsapce from the api.
:return: An int between 0 and 3
"""
return json.loads(requests.get(API_URL_GET_PARK).content)["id"]
@staticmethod
def pay_park() -> bool:
"""Pay for parking.
:return: True if successful, False if not successful
"""
return requests.get(API_URL_PAY_PARK).status_code == 200
@staticmethod
def simon_says() -> int:
"""Get next simon says zone from the api.
:return: An int between 0 and 3 or -1 after making this request 5 times.
"""
return json.loads(requests.get(API_URL_SIMON_SAYS).content)["id"]
@ -35,20 +44,32 @@ class Position:
class DoubleElim:
@staticmethod
def get_position():
def get_position() -> Position:
"""Get position of the robot
:return: A Position object with robot position
"""
response = json.loads(requests.get(API_URL_GET_POS).content)
return Position(response["x"], response["y"], response["degrees"])
@staticmethod
def get_opponent():
def get_opponent() -> Position:
"""Get position of the opponents robot
:return: A Position object with opponents robot position
"""
response = json.loads(requests.get(API_URL_GET_OP).content)
return Position(response["x"], response["y"], response["degrees"])
@staticmethod
def get_goal():
def get_goal() -> Position:
"""Get position of the goal
:return: A Position object with x and y coordinates of the goal, rotation is always -1
"""
response = json.loads(requests.get(API_URL_GET_GOAL).content)
return Position(response["x"], response["y"], -1)
@staticmethod
def get_items():
def get_items() -> list:
"""Get a list with all current items
:return: A list will all items currently on the game field. Items are dictionaries that look like: {"id": 0}
"""
return json.loads(requests.get(API_URL_GET_ITEMS).content)

View file

@ -1,25 +0,0 @@
#!/usr/bin/env bash
# DO NOT RUN UNLESS YOUR REALLY KNOW WHAT YOU ARE DOING
DEBEMAIL="joel.klimont@gmail.com"
DEBFULLNAME="Joel Klimont"
export DEBEMAIL DEBFULLNAME
python3 setup.py sdist
cd dist || exit
tar -xzmf *.tar.gz
cd complib-0.0.1 || exit
git init
git remote add origin https://github.com/F-WuTS/complib-DEB.git
git fetch origin
git checkout -b master --track origin/master
gbp import-orig -u 0.0.1 --pristine-tar --sign-tags --no-interactive ../complib-0.0.1.tar.gz
mv setup.py setup.py.old
echo "#!/usr/bin/env python3" >> setup.py
cat setup.py.old >> setup.py
debmake -b":python3"
mv setup.py.old setup.py
git add debian/
git commit -m "init"
gbp buildpackage --git-pristine-tar --git-sign-tags --git-keyid=97B61E4D515353C0A498D2AB22680B5AAC0C4FCE
git push --set-upstream origin master

14
postinstall.sh Normal file
View file

@ -0,0 +1,14 @@
install_package() {
echo "Installing package '$1' via pip3"
pip3 install "$1"
if [ $? -eq 0 ]; then
echo "Successfully installed pip3 package '$1'"
else
echo "Could not install pip3 package '$1'"
exit 1
fi
}
install_package "smbus"
install_package "requests"
install_package "python-logstash-async"

View file

@ -26,15 +26,10 @@ setuptools.setup(
"License :: Other/Proprietary License",
"Operating System :: Unix"
],
license="proprietary",
install_requires=[
"smbus",
"requests",
"python-logstash-async"
],
setup_requires=[
"smbus",
"requests",
"python-logstash-async"
]
license="proprietary"#,
#install_requires=[
# "smbus",
# "requests",
# "python-logstash-async"
#]
)