From ddba99bfd8557a46f3231ca05021bc7068c3bec4 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 10 Aug 2022 11:28:10 +0100 Subject: [PATCH 1/3] monitor: Handle NavRouteClear & un-() an assert * Stop trying to load `NavRoute.json` if it contained a `NavRouteClear`. * `assert` is a *keyword*, not a function. --- monitor.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/monitor.py b/monitor.py index eb9fbfb3..859b2a50 100644 --- a/monitor.py +++ b/monitor.py @@ -1469,7 +1469,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state[category].pop(material) module = self.state['Modules'][entry['Slot']] - assert(module['Item'] == self.canonicalise(entry['Module'])) + assert module['Item'] == self.canonicalise(entry['Module']) module['Engineering'] = { 'Engineer': entry['Engineer'], 'EngineerID': entry['EngineerID'], @@ -2300,9 +2300,15 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below ) return False - # everything is good, lets set what we need to and make sure we dont try again - logger.info('Successfully read NavRoute file for last NavRoute event.') - self.state['NavRoute'] = file + # Handle it being `NavRouteClear`d already + if file['event'].lower() == 'navrouteclear': + logger.info('NavRoute file contained a NavRouteClear') + # We do *NOT* copy into/clear the `self.state['NavRoute']` + else: + # everything is good, lets set what we need to and make sure we dont try again + logger.info('Successfully read NavRoute file for last NavRoute event.') + self.state['NavRoute'] = file + self._navroute_retries_remaining = 0 self._last_navroute_journal_timestamp = None return True From 1bb0bf9f74fcfee2a0b64da036b63a7a92e23af3 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 10 Aug 2022 11:47:51 +0100 Subject: [PATCH 2/3] PLUGINS.md: Document `NavRouteClear` behaviour --- PLUGINS.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/PLUGINS.md b/PLUGINS.md index b26ee58b..be479920 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -698,6 +698,18 @@ New in version 5.1.1: `state` now has a `ShipLockerJSON` member containing the un-changed, loaded, JSON from the `ShipLockerJSON.json` file. +New in version 5.4.2+: + +We now handle the 'Update 13' `NavRouteClear` event by detecting if that's what +is in the `NavRoute.json` file. If this is the case then we log that, **but +do NOT clear `state['NavRoute']`**. Plugins will get sent the Journal +`NavRouteClear` event anyway, and there might be some value to them retaining +access to the prior plotted route. + +NB: It *is* possible, if a player is quick enough, to plot and clear a route +before we load it, in which case we'd be retaining the *previous* plotted +route. + ___ ##### Synthetic Events From f28228285a5c6443d71687305f31c4dda3943a67 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 10 Aug 2022 11:51:23 +0100 Subject: [PATCH 3/3] plugins/eddn: Do *NOT* alert user on 'no Route in NavRoute' This can simply occur if the *first* load of `NavRoute.json` soft-fails, meaning the plugin is receiving the bare Journal-file event, which has no `Route` array. --- plugins/eddn.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 4bea9bcd..b369e415 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -1111,8 +1111,10 @@ class EDDN: # Sanity check - Ref Issue 1342 if 'Route' not in entry: logger.warning(f"NavRoute didn't contain a Route array!\n{entry!r}") - # LANG: No 'Route' found in NavRoute.json file - return _("No 'Route' array in NavRoute.json contents") + # This can happen if first-load of the file failed, and we're simply + # passing through the bare Journal event, so no need to alert + # the user. + return None ####################################################################### # Elisions