From c855410ec6369c236e45f22f6f4529c0aa6f9ded Mon Sep 17 00:00:00 2001 From: Rafael Sillero Date: Mon, 22 Jan 2024 09:50:14 +0100 Subject: [PATCH 1/4] Fix issue when waiting for cooldown of a ship that would end up in a negative time_to_sleep and therefore throw an exception --- autotraders/ship/__init__.py | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/autotraders/ship/__init__.py b/autotraders/ship/__init__.py index 8dd7fc1..698f249 100644 --- a/autotraders/ship/__init__.py +++ b/autotraders/ship/__init__.py @@ -79,7 +79,7 @@ class Ship(SpaceTradersEntity): cooldown: Optional[Cooldown] def __init__( - self, symbol, session: AutoTradersSession, data: Optional[dict] = None + self, symbol, session: AutoTradersSession, data: Optional[dict] = None ): if symbol is None: symbol = data["symbol"] @@ -113,37 +113,35 @@ def __str__(self): def wait_transit(self): if ( - sleep_time := ( - self.nav.route.arrival - datetime.now(timezone.utc) - ).total_seconds() - + 0.5 - > 0 + sleep_time := ( + self.nav.route.arrival - datetime.now(timezone.utc) + ).total_seconds() + + 0.5 + > 0 ): time.sleep(sleep_time) async def await_transit(self): if ( - sleep_time := ( - self.nav.route.arrival - datetime.now(timezone.utc) - ).total_seconds() - + 0.5 - > 0 + sleep_time := ( + self.nav.route.arrival - datetime.now(timezone.utc) + ).total_seconds() + + 0.5 + > 0 ): await asyncio.sleep(sleep_time) def wait_cooldown(self): if self.cooldown is not None: - time.sleep( - (self.cooldown.expiration - datetime.now(timezone.utc)).total_seconds() - + 1 - ) + time_to_sleep = (self.cooldown.expiration - datetime.now(timezone.utc)).total_seconds() + 1 + if time_to_sleep > 0: + time.sleep(time_to_sleep) async def await_cooldown(self): if self.cooldown is not None: - await asyncio.sleep( - (self.cooldown.expiration - datetime.now(timezone.utc)).total_seconds() - + 1 - ) + time_to_sleep = (self.cooldown.expiration - datetime.now(timezone.utc)).total_seconds() + 1 + if time_to_sleep > 0: + await asyncio.sleep(time_to_sleep) def navigate(self, waypoint: Union[str, MapSymbol]): """Attempts to move ship to the provided waypoint. From 27b40036dd413420c8996eefeecf91f8f70eb0bb Mon Sep 17 00:00:00 2001 From: Rafael Sillero Date: Mon, 22 Jan 2024 09:52:11 +0100 Subject: [PATCH 2/4] Fix issue when waiting for a transit that would end up in a negative time_to_sleep and therefore throw an exception --- autotraders/ship/__init__.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/autotraders/ship/__init__.py b/autotraders/ship/__init__.py index 698f249..5557b43 100644 --- a/autotraders/ship/__init__.py +++ b/autotraders/ship/__init__.py @@ -112,23 +112,13 @@ def __str__(self): return self.symbol def wait_transit(self): - if ( - sleep_time := ( - self.nav.route.arrival - datetime.now(timezone.utc) - ).total_seconds() - + 0.5 - > 0 - ): + sleep_time = (self.nav.route.arrival - datetime.now(timezone.utc)).total_seconds() + 0.5 + if sleep_time > 0: time.sleep(sleep_time) async def await_transit(self): - if ( - sleep_time := ( - self.nav.route.arrival - datetime.now(timezone.utc) - ).total_seconds() - + 0.5 - > 0 - ): + sleep_time = (self.nav.route.arrival - datetime.now(timezone.utc)).total_seconds() + 0.5 + if sleep_time > 0: await asyncio.sleep(sleep_time) def wait_cooldown(self): From 690941ba4e403ae5957d7eed47b6f4412e3c121e Mon Sep 17 00:00:00 2001 From: Rafael Sillero Date: Mon, 29 Jan 2024 23:35:57 +0100 Subject: [PATCH 3/4] Fix issue that ends up not iterating all the pages in a Paginated result --- autotraders/paginated_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotraders/paginated_list.py b/autotraders/paginated_list.py index 8d59655..8ad2974 100644 --- a/autotraders/paginated_list.py +++ b/autotraders/paginated_list.py @@ -38,7 +38,7 @@ def prev(self): def all(self): """Gets all the pages and returns the list of all pages""" - for page in range(1, self.pages): + for page in range(1, self.pages + 1): self.page = page self.current() return self.stitch() From d243ea4c0ab272a7f0c07804a293062acb19e694 Mon Sep 17 00:00:00 2001 From: Rafael Sillero Date: Mon, 5 Feb 2024 13:04:14 +0100 Subject: [PATCH 4/4] Update CHANGELOG.md to reflect past versions Add RSilNav to authors, as I intend to maintain my own fork of the project and keep it updated --- CHANGELOG.md | 91 +++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index deb98f6..8ec764f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,93 @@ -# v2.0.0 (unreleased) +# v2.3.4 + +- Fix issue with Contract deliver endpoint not able to return the right… by @Rsilnav in #14 +- Fixed issue with nav.origin returning the wrong symbol + +# v2.3.3 + +- UPDATED: Updated API version support to Dec. 2 +- FIXED: minor marketplace error + +# v2.3.2 + +- Bugfix + +# v2.3.1 + +- FIXED: Bugs + +# v2.3.0 + +- BREAKING: Route.origin and Route.destination are now Waypoints +- ADDED: Overloaders to many smaller classes +- FIXED: many bugs + +# v2.2.8 + +- FIXED: Issue where h2 wasn't being installed +- FIXED: more api bugs + +# v2.2.7 + +- More bug fixing + +# v2.2.6 + +- FIXED: Issue with Activity being required + +# v2.2.5 + +- BREAKING: API updated to support v2.1 (All previous API versions are now unsupported) +- ADDED: Some enums for market trade goods + +# v2.2.4 + +- FIXED: More packaging issues + +# v2.2.3 + +- FIXED: More packaging issues + +# v2.2.2 + +- FIXED: GitHub python package publishing + +# v2.2.1 + +- UPDATED: pyrate is now 3.0+ +- FIXED: GitHub python package publishing + +# v2.2.0 + +- ADDED: cooldown.active attribute +- UPDATED: Moved version stuff to version.py and added more version info +- UPDATED: Formatting + +# v2.1.0 + +- BREAKING: The Update Ship Cooldown from the Ship class has been removed. +- ADDED: Method to get the cost effective refuel amount to the Fuel class. +- FIXED: Bug that limited retries to one less than what they should be +- FIXED: Bug that caused the wait_for_transit and the equivalent async version to error if there wasn't any transit happening. + +# v2.0.4 + +- UPDATED: New server changes. + +# v2.0.3 + +- Releasing Update + +# v2.0.2 + +- FIXED: Rogue print statement +- FIXED: ship.nav warping instead of navigating + +# v2.0.1 + +- FIXED: Various bugs + +# v2.0.0 - BREAKING: Dropped requests as a dependency, switched to httpx - BREAKING: Added and enabled http2 diff --git a/pyproject.toml b/pyproject.toml index 6077666..c74bb94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ build-backend = "setuptools.build_meta" name = "autotraders" authors = [ { name = "Ashwin Naren", email = "arihant2math@gmail.com" }, + { name = "Rafael Sillero", email = "rafael.silnav@gmail.com" }, ] description = "A powerful spacetraders API" readme = "README.md"