diff --git a/build.sh b/build.sh deleted file mode 100644 index 6b518df..0000000 --- a/build.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/build_deb.sh b/build_deb.sh new file mode 100644 index 0000000..3ac3f82 --- /dev/null +++ b/build_deb.sh @@ -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" ' \ + --license 'proprietary' \ + --description 'Library for robot used in the competition' \ + --after-install postinstall.sh \ + -v 0.0.2 -t deb setup.py diff --git a/build_newversion.sh b/build_newversion.sh deleted file mode 100644 index ddbc170..0000000 --- a/build_newversion.sh +++ /dev/null @@ -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 diff --git a/compLib/Api.py b/compLib/Api.py index b977402..060bd1a 100644 --- a/compLib/Api.py +++ b/compLib/Api.py @@ -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) diff --git a/init_build.sh b/init_build.sh deleted file mode 100755 index 1cedad2..0000000 --- a/init_build.sh +++ /dev/null @@ -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 diff --git a/postinstall.sh b/postinstall.sh new file mode 100644 index 0000000..1bb1f0b --- /dev/null +++ b/postinstall.sh @@ -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" \ No newline at end of file diff --git a/setup.py b/setup.py index 5aa0da1..db795ac 100644 --- a/setup.py +++ b/setup.py @@ -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" + #] )