From df9f0bfc7c383f8b1a27c7dc3957e9f89f1c4cff Mon Sep 17 00:00:00 2001 From: Chris Henning Date: Sun, 12 Jun 2022 15:26:50 -0400 Subject: [PATCH 1/8] Implement FSSSignalDiscovered sender v1 --- plugins/eddn.py | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/plugins/eddn.py b/plugins/eddn.py index ff4729a1..998cdb81 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -152,6 +152,7 @@ class EDDN: self.session.headers['User-Agent'] = user_agent self.replayfile: Optional[TextIO] = None # For delayed messages self.replaylog: List[str] = [] + self.fsssignals: Optional[Mapping[str, Any]] = None if config.eddn_url is not None: self.eddn_url = config.eddn_url @@ -1307,6 +1308,94 @@ class EDDN: this.eddn.export_journal_entry(cmdr, entry, msg) return None + def batch_journal_fsssignaldiscovered( + self, cmdr: str, system_name: str, system_starpos: list, is_beta: bool, entry: MutableMapping[str, Any] + ) -> Optional[str]: + """ + Augment and keep FSSSignalDiscovered journal events + + :param cmdr: the commander under which this upload is made + :param system_name: Name of current star system + :param system_starpos: Coordinates of current star system + :param is_beta: whether or not we are in beta mode + :param entry: the journal entry to batch + """ + #{ + # "timestamp": "2021-01-15T02:54:18Z", + # "event": "FSSSignalDiscovered", + # "SystemAddress": 1900279744859, + # "SignalName": "$USS_HighGradeEmissions;", + # "SignalName_Localised": "Unidentified signal source", + # "USSType": "$USS_Type_ValuableSalvage;", + # "USSType_Localised": "Encoded emissions", + # "SpawningState": "", + # "SpawningFaction": "Free Marlinists of Carinae", + # "ThreatLevel": 0, + # "TimeRemaining": 718.508789 + #} + ####################################################################### + #logger.trace_if("plugin.eddn", entry) + # Elisions + entry = filter_localised(entry) + if "USSType" in entry and entry["USSType"] == "$USS_Type_MissionTarget;": + logger.warning("USSType is $USS_Type_MissionTarget;, dropping") + return 'Dropping $USS_Type_MissionTarget;' + # Can check SystemAddress here, but we'll remove it from this signal list, to be added to the outer batched message + if this.systemaddress is None or this.systemaddress != entry['SystemAddress']: + logger.warning("SystemAddress isn't current location! Can't add augmentations!") + return 'Wrong System! Missed jump ?' + + # Horizons/Odyssey will be readded later + for removekey in ["TimeRemaining", "horizons", "odyssey", "SystemAddress" ]: + if removekey in entry: + entry.pop(removekey) + ####################################################################### + + if not self.fsssignals: + self.fsssignals = [] + if entry is not None and entry != "": + logger.trace_if("plugin.eddn", f"Appending FSSSignalDiscovered entry: {json.dumps(entry)}") + self.fsssignals.append(entry) + + def export_journal_fsssignaldiscovered( + self, cmdr: str, system_name: str, system_starpos: list, is_beta: bool, entry: MutableMapping[str, Any] + ) -> Optional[str]: + logger.trace_if("plugin.eddn", f"This non-FSSS entry is {json.dumps(entry)}") + """ + Send an FSSSignalDiscovered message to EDDN on the correct schema. + + :param cmdr: the commander under which this upload is made + :param system_name: Name of current star system + :param system_starpos: Coordinates of current star system + :param is_beta: whether or not we are in beta mode + :param entry: the non-FSSSignalDiscovered journal entry that triggered this batch send + """ + msg = { + '$schemaRef': f'https://eddn.edcd.io/schemas/fsssignaldiscovered/1{"/test" if is_beta else ""}', + 'message': { + "event":"FSSSignalDiscovered", + "signals": self.fsssignals + } + } + # Readd Horizons and Odyssey to the outer message not each signal + for gamever in [ "horizons", "odyssey" ]: + if gamever in entry and gamever not in msg: + msg[gamever] = entry[gamever] + + # Another SystemAddress check, however: some events won't have it. Is it an issue? + if this.systemaddress is None or ('SystemAddress' in entry and this.systemaddress != entry['SystemAddress']): + logger.warning("SystemAddress isn't current location! Can't add augmentations!") + return 'Wrong System! Missed jump ?' + + ret = this.eddn.entry_augment_system_data(msg, system_name, system_starpos) + if isinstance(ret, str): + return ret + + logger.trace_if("plugin.eddn", f"FSSSignalDiscovered batch is {json.dumps(msg)}") + this.eddn.export_journal_entry(cmdr, self.fsssignals[-1], msg) + self.fsssignals = None + return None + def canonicalise(self, item: str) -> str: """ Canonicalise the given commodity name. @@ -1657,6 +1746,18 @@ def journal_entry( # noqa: C901, CCR001 # drop those events, or if the schema allows, send without those # augmentations. + elif event_name == 'fsssignaldiscovered': + # Drop the event if we don't know system/starpos. Do something else? + if system is None or 'StarPos' not in state or state['StarPos'] is None: + return "" + this.eddn.batch_journal_fsssignaldiscovered( + cmdr, + system, + state['StarPos'], + is_beta, + entry + ) + elif event_name == 'fssallbodiesfound': return this.eddn.export_journal_fssallbodiesfound( cmdr, @@ -1674,6 +1775,15 @@ def journal_entry( # noqa: C901, CCR001 is_beta, entry ) + # Simple queue: send batched FSSSignalDiscovereds once a non-FSSSignalDiscovered is observed + if event_name != 'fsssignaldiscovered' and this.eddn.fsssignals is not None and len(this.eddn.fsssignals) > 0: + return this.eddn.export_journal_fsssignaldiscovered( + cmdr, + system, + state['StarPos'], + is_beta, + entry + ) # Send journal schema events to EDDN, but not when on a crew if (config.get_int('output') & config.OUT_SYS_EDDN and not state['Captain'] and From 1b3799101670a307bd52188f7e446fc6e51e4ff2 Mon Sep 17 00:00:00 2001 From: Chris Henning Date: Sun, 12 Jun 2022 16:16:54 -0400 Subject: [PATCH 2/8] fix flake8 errors --- plugins/eddn.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 998cdb81..8b672cec 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -256,6 +256,8 @@ class EDDN: headers = {'Content-Encoding': 'gzip'} r = self.session.post(self.eddn_url, data=encoded, timeout=self.TIMEOUT, headers=headers) + logger.trace_if('plugin.eddn', f"EDDN response {r.status_code} to data: {json.dumps(to_send)}") + logger.trace_if('plugin.eddn', f"EDDN response {r.text}") if r.status_code != requests.codes.ok: # Check if EDDN is still objecting to an empty commodities list @@ -1310,7 +1312,7 @@ class EDDN: def batch_journal_fsssignaldiscovered( self, cmdr: str, system_name: str, system_starpos: list, is_beta: bool, entry: MutableMapping[str, Any] - ) -> Optional[str]: + ) -> Optional[str]: """ Augment and keep FSSSignalDiscovered journal events @@ -1320,7 +1322,7 @@ class EDDN: :param is_beta: whether or not we are in beta mode :param entry: the journal entry to batch """ - #{ + # { # "timestamp": "2021-01-15T02:54:18Z", # "event": "FSSSignalDiscovered", # "SystemAddress": 1900279744859, @@ -1332,30 +1334,29 @@ class EDDN: # "SpawningFaction": "Free Marlinists of Carinae", # "ThreatLevel": 0, # "TimeRemaining": 718.508789 - #} + # } ####################################################################### - #logger.trace_if("plugin.eddn", entry) # Elisions entry = filter_localised(entry) if "USSType" in entry and entry["USSType"] == "$USS_Type_MissionTarget;": logger.warning("USSType is $USS_Type_MissionTarget;, dropping") return 'Dropping $USS_Type_MissionTarget;' - # Can check SystemAddress here, but we'll remove it from this signal list, to be added to the outer batched message + # Can check SystemAddress here, but we'll remove it from this signal list, to be added to the batch if this.systemaddress is None or this.systemaddress != entry['SystemAddress']: logger.warning("SystemAddress isn't current location! Can't add augmentations!") return 'Wrong System! Missed jump ?' # Horizons/Odyssey will be readded later - for removekey in ["TimeRemaining", "horizons", "odyssey", "SystemAddress" ]: + for removekey in ["TimeRemaining", "horizons", "odyssey", "SystemAddress"]: if removekey in entry: entry.pop(removekey) ####################################################################### if not self.fsssignals: - self.fsssignals = [] + self.fsssignals = [] if entry is not None and entry != "": - logger.trace_if("plugin.eddn", f"Appending FSSSignalDiscovered entry: {json.dumps(entry)}") - self.fsssignals.append(entry) + logger.trace_if("plugin.eddn", f"Appending FSSSignalDiscovered entry: {json.dumps(entry)}") + self.fsssignals.append(entry) def export_journal_fsssignaldiscovered( self, cmdr: str, system_name: str, system_starpos: list, is_beta: bool, entry: MutableMapping[str, Any] @@ -1373,7 +1374,7 @@ class EDDN: msg = { '$schemaRef': f'https://eddn.edcd.io/schemas/fsssignaldiscovered/1{"/test" if is_beta else ""}', 'message': { - "event":"FSSSignalDiscovered", + "event": "FSSSignalDiscovered", "signals": self.fsssignals } } From 4dfcd91bcd2266c50525a19b752a0ef74e93f4e8 Mon Sep 17 00:00:00 2001 From: Chris Henning Date: Sun, 12 Jun 2022 16:19:25 -0400 Subject: [PATCH 3/8] fix more flake8 errors --- plugins/eddn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 8b672cec..51ae523b 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -1379,9 +1379,9 @@ class EDDN: } } # Readd Horizons and Odyssey to the outer message not each signal - for gamever in [ "horizons", "odyssey" ]: - if gamever in entry and gamever not in msg: - msg[gamever] = entry[gamever] + for gamever in ["horizons", "odyssey"]: + if gamever in entry and gamever not in msg: + msg[gamever] = entry[gamever] # Another SystemAddress check, however: some events won't have it. Is it an issue? if this.systemaddress is None or ('SystemAddress' in entry and this.systemaddress != entry['SystemAddress']): From 4bf2965cc5fa439bbbb6447f22a9e3e828ef5ad2 Mon Sep 17 00:00:00 2001 From: Chris Henning Date: Sun, 12 Jun 2022 17:12:08 -0400 Subject: [PATCH 4/8] remove unnecessarily committed debug messages --- plugins/eddn.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 51ae523b..bc458494 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -256,8 +256,6 @@ class EDDN: headers = {'Content-Encoding': 'gzip'} r = self.session.post(self.eddn_url, data=encoded, timeout=self.TIMEOUT, headers=headers) - logger.trace_if('plugin.eddn', f"EDDN response {r.status_code} to data: {json.dumps(to_send)}") - logger.trace_if('plugin.eddn', f"EDDN response {r.text}") if r.status_code != requests.codes.ok: # Check if EDDN is still objecting to an empty commodities list From afda16853bf01cb16da47e1cc2be5c23210c4136 Mon Sep 17 00:00:00 2001 From: Chris Henning Date: Sun, 12 Jun 2022 17:59:18 -0400 Subject: [PATCH 5/8] Change this log to debug level --- plugins/eddn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index bc458494..79d0ac81 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -1337,7 +1337,7 @@ class EDDN: # Elisions entry = filter_localised(entry) if "USSType" in entry and entry["USSType"] == "$USS_Type_MissionTarget;": - logger.warning("USSType is $USS_Type_MissionTarget;, dropping") + logger.debug("USSType is $USS_Type_MissionTarget;, dropping") return 'Dropping $USS_Type_MissionTarget;' # Can check SystemAddress here, but we'll remove it from this signal list, to be added to the batch if this.systemaddress is None or this.systemaddress != entry['SystemAddress']: From d5ec54dbea99ae43563afbe50a2cc9e37c5ddd12 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 15 Jun 2022 12:11:01 +0100 Subject: [PATCH 6/8] eddn/fsssignaldiscovered: Start on cleaning up chennin's work --- plugins/eddn.py | 82 +++++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 58 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 79d0ac81..7d1d6075 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -152,7 +152,7 @@ class EDDN: self.session.headers['User-Agent'] = user_agent self.replayfile: Optional[TextIO] = None # For delayed messages self.replaylog: List[str] = [] - self.fsssignals: Optional[Mapping[str, Any]] = None + self.fss_signals: List[Mapping[str, Any]] = [] if config.eddn_url is not None: self.eddn_url = config.eddn_url @@ -1308,31 +1308,33 @@ class EDDN: this.eddn.export_journal_entry(cmdr, entry, msg) return None - def batch_journal_fsssignaldiscovered( + def enqueue_journal_fsssignaldiscovered(self, entry: MutableMapping[str, Any]) -> None: + """ + Queue up an FSSSignalDiscovered journal event for later sending. + + :param entry: the journal entry to batch + """ + if entry is None or entry == "": + logger.warning(f"Supplied event was empty: {entry!r}") + return + + logger.trace_if("plugin.eddn.fsssignaldiscovered", f"Appending FSSSignalDiscovered entry:\n" + f" {json.dumps(entry)}") + self.fss_signals.append(entry) + + def export_journal_fsssignaldiscovered( self, cmdr: str, system_name: str, system_starpos: list, is_beta: bool, entry: MutableMapping[str, Any] ) -> Optional[str]: """ - Augment and keep FSSSignalDiscovered journal events + Send an FSSSignalDiscovered message to EDDN on the correct schema. :param cmdr: the commander under which this upload is made :param system_name: Name of current star system :param system_starpos: Coordinates of current star system :param is_beta: whether or not we are in beta mode - :param entry: the journal entry to batch + :param entry: the non-FSSSignalDiscovered journal entry that triggered this batch send """ - # { - # "timestamp": "2021-01-15T02:54:18Z", - # "event": "FSSSignalDiscovered", - # "SystemAddress": 1900279744859, - # "SignalName": "$USS_HighGradeEmissions;", - # "SignalName_Localised": "Unidentified signal source", - # "USSType": "$USS_Type_ValuableSalvage;", - # "USSType_Localised": "Encoded emissions", - # "SpawningState": "", - # "SpawningFaction": "Free Marlinists of Carinae", - # "ThreatLevel": 0, - # "TimeRemaining": 718.508789 - # } + logger.trace_if("plugin.eddn", f"This non-FSSS entry is {json.dumps(entry)}") ####################################################################### # Elisions entry = filter_localised(entry) @@ -1350,30 +1352,11 @@ class EDDN: entry.pop(removekey) ####################################################################### - if not self.fsssignals: - self.fsssignals = [] - if entry is not None and entry != "": - logger.trace_if("plugin.eddn", f"Appending FSSSignalDiscovered entry: {json.dumps(entry)}") - self.fsssignals.append(entry) - - def export_journal_fsssignaldiscovered( - self, cmdr: str, system_name: str, system_starpos: list, is_beta: bool, entry: MutableMapping[str, Any] - ) -> Optional[str]: - logger.trace_if("plugin.eddn", f"This non-FSSS entry is {json.dumps(entry)}") - """ - Send an FSSSignalDiscovered message to EDDN on the correct schema. - - :param cmdr: the commander under which this upload is made - :param system_name: Name of current star system - :param system_starpos: Coordinates of current star system - :param is_beta: whether or not we are in beta mode - :param entry: the non-FSSSignalDiscovered journal entry that triggered this batch send - """ msg = { '$schemaRef': f'https://eddn.edcd.io/schemas/fsssignaldiscovered/1{"/test" if is_beta else ""}', 'message': { "event": "FSSSignalDiscovered", - "signals": self.fsssignals + "signals": self.fss_signals } } # Readd Horizons and Odyssey to the outer message not each signal @@ -1391,8 +1374,8 @@ class EDDN: return ret logger.trace_if("plugin.eddn", f"FSSSignalDiscovered batch is {json.dumps(msg)}") - this.eddn.export_journal_entry(cmdr, self.fsssignals[-1], msg) - self.fsssignals = None + this.eddn.export_journal_entry(cmdr, self.fss_signals[-1], msg) + self.fss_signals = [] return None def canonicalise(self, item: str) -> str: @@ -1737,25 +1720,8 @@ def journal_entry( # noqa: C901, CCR001 entry ) - # NB: If adding FSSSignalDiscovered these absolutely come in at login - # time **BEFORE** the `Location` event, so we won't yet know things - # like SystemName, or StarPos. - # We can either have the "now send the batch" code add such (but - # that has corner cases around changing systems in the meantime), - # drop those events, or if the schema allows, send without those - # augmentations. - elif event_name == 'fsssignaldiscovered': - # Drop the event if we don't know system/starpos. Do something else? - if system is None or 'StarPos' not in state or state['StarPos'] is None: - return "" - this.eddn.batch_journal_fsssignaldiscovered( - cmdr, - system, - state['StarPos'], - is_beta, - entry - ) + this.eddn.enqueue_journal_fsssignaldiscovered(entry) elif event_name == 'fssallbodiesfound': return this.eddn.export_journal_fssallbodiesfound( @@ -1775,7 +1741,7 @@ def journal_entry( # noqa: C901, CCR001 entry ) # Simple queue: send batched FSSSignalDiscovereds once a non-FSSSignalDiscovered is observed - if event_name != 'fsssignaldiscovered' and this.eddn.fsssignals is not None and len(this.eddn.fsssignals) > 0: + if event_name != 'fsssignaldiscovered' and this.eddn.fss_signals is not None and len(this.eddn.fss_signals) > 0: return this.eddn.export_journal_fsssignaldiscovered( cmdr, system, From 37c88aeefc419b8a3bea320d0ad19ababf777da7 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 15 Jun 2022 13:19:13 +0100 Subject: [PATCH 7/8] eddn/fsssignaldiscovered: Further cleanup * Move call to `export_journal_fsssignaldiscovered` to top-level of event processing. This ensures we'd still have the *previous* system tracked when running under Odyssey. Also, we can't return any result from this, as we'd still need to process things like `Location` otherwise. * Use `logger.trace_if("plugin.eddn.fsssignaldiscovered", ...)` * Perform all sanity checks, elisions and augmentations in the "not FSSSignalDiscovered event" sending code. --- plugins/eddn.py | 108 +++++++++++++++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 39 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 7d1d6075..2c8e8916 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -1334,48 +1334,75 @@ class EDDN: :param is_beta: whether or not we are in beta mode :param entry: the non-FSSSignalDiscovered journal entry that triggered this batch send """ - logger.trace_if("plugin.eddn", f"This non-FSSS entry is {json.dumps(entry)}") + logger.trace_if("plugin.eddn.fsssignaldiscovered", f"This other event is: {json.dumps(entry)}") ####################################################################### - # Elisions - entry = filter_localised(entry) - if "USSType" in entry and entry["USSType"] == "$USS_Type_MissionTarget;": - logger.debug("USSType is $USS_Type_MissionTarget;, dropping") - return 'Dropping $USS_Type_MissionTarget;' - # Can check SystemAddress here, but we'll remove it from this signal list, to be added to the batch - if this.systemaddress is None or this.systemaddress != entry['SystemAddress']: - logger.warning("SystemAddress isn't current location! Can't add augmentations!") + # Location cross-check and augmentation setup + ####################################################################### + # Determine if this is Horizons order or Odyssey order + if entry['event'] in ('Location', 'FSDJump', 'CarrierJump'): + # Odyssey order, use this new event's data for cross-check + aug_systemaddress = entry['SystemAddress'] + aug_starsystem = entry['StarSystem'] + aug_starpos = entry['StarPos'] + + else: + # Horizons order, so use tracked data for cross-check + aug_systemaddress = this.systemaddress + aug_starsystem = system_name + aug_starpos = system_starpos + + if aug_systemaddress != self.fss_signals[0]['SystemAddress']: + logger.warning("First signal's SystemAddress doesn't match current location: " + f"{self.fss_signals[0]['SystemAddress']} != {aug_systemaddress}") + self.fss_signals = [] return 'Wrong System! Missed jump ?' - - # Horizons/Odyssey will be readded later - for removekey in ["TimeRemaining", "horizons", "odyssey", "SystemAddress"]: - if removekey in entry: - entry.pop(removekey) ####################################################################### - msg = { + # Build basis of message + msg: Dict = { '$schemaRef': f'https://eddn.edcd.io/schemas/fsssignaldiscovered/1{"/test" if is_beta else ""}', 'message': { - "event": "FSSSignalDiscovered", - "signals": self.fss_signals + "event": "FSSSignalDiscovered", + "timestamp": self.fss_signals[0]['timestamp'], + "SystemAddress": aug_systemaddress, + "StarSystem": aug_starsystem, + "StarPos": aug_starpos, + "signals": [], } } - # Readd Horizons and Odyssey to the outer message not each signal - for gamever in ["horizons", "odyssey"]: - if gamever in entry and gamever not in msg: - msg[gamever] = entry[gamever] - # Another SystemAddress check, however: some events won't have it. Is it an issue? - if this.systemaddress is None or ('SystemAddress' in entry and this.systemaddress != entry['SystemAddress']): - logger.warning("SystemAddress isn't current location! Can't add augmentations!") - return 'Wrong System! Missed jump ?' + # Now add the signals, checking each is for the correct system, dropping + # any that aren't, and applying necessary elisions. + for s in self.fss_signals: + if s['SystemAddress'] != aug_systemaddress: + logger.warning("Signal's SystemAddress not current system, dropping: " + f"{s['SystemAddress']} != {aug_systemaddress}") + continue - ret = this.eddn.entry_augment_system_data(msg, system_name, system_starpos) - if isinstance(ret, str): - return ret + # Remove any _Localised keys (would only be in a USS signal) + s = filter_localised(s) - logger.trace_if("plugin.eddn", f"FSSSignalDiscovered batch is {json.dumps(msg)}") - this.eddn.export_journal_entry(cmdr, self.fss_signals[-1], msg) + # Drop Mission USS signals. + if "USSType" in s and s["USSType"] == "$USS_Type_MissionTarget;": + logger.trace_if("plugin.eddn.fsssignaldiscovered", "USSType is $USS_Type_MissionTarget;, dropping") + continue + + # Remove any `TimeRemaining` (USS) or `SystemAddress` keys + s.pop('TimeRemaining', None) + s.pop('SystemAddress', None) + + msg['message']['signals'].append(s) + + # `horizons` and `odyssey` augmentations + msg['message']['horizons'] = entry['Horizons'] + msg['message']['odyssey'] = entry['Odyssey'] + + logger.trace_if("plugin.eddn.fsssignaldiscovered", f"FSSSignalDiscovered batch is {json.dumps(msg)}") + + # Fake an 'entry' as it's only there for some "should we send replay?" checks in the called function. + this.eddn.export_journal_entry(cmdr, {'entry': 'send_fsssignaldiscovered'}, msg) self.fss_signals = [] + return None def canonicalise(self, item: str) -> str: @@ -1628,6 +1655,18 @@ def journal_entry( # noqa: C901, CCR001 this.horizons = entry['horizons'] = state['Horizons'] this.odyssey = entry['odyssey'] = state['Odyssey'] + # Simple queue: send batched FSSSignalDiscovered once a non-FSSSignalDiscovered is observed + if event_name != 'fsssignaldiscovered' and this.eddn.fss_signals: + # We can't return here, we still might need to otherwise process this event, + # so errors will never be shown to the user. + this.eddn.export_journal_fsssignaldiscovered( + cmdr, + system, + state['StarPos'], + is_beta, + entry + ) + # Track location if event_name == 'supercruiseexit': # For any orbital station we have no way of determining the body @@ -1740,15 +1779,6 @@ def journal_entry( # noqa: C901, CCR001 is_beta, entry ) - # Simple queue: send batched FSSSignalDiscovereds once a non-FSSSignalDiscovered is observed - if event_name != 'fsssignaldiscovered' and this.eddn.fss_signals is not None and len(this.eddn.fss_signals) > 0: - return this.eddn.export_journal_fsssignaldiscovered( - cmdr, - system, - state['StarPos'], - is_beta, - entry - ) # Send journal schema events to EDDN, but not when on a crew if (config.get_int('output') & config.OUT_SYS_EDDN and not state['Captain'] and From 77203c72274a411f4ec7532dbe117d9d8d435dee Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 15 Jun 2022 14:34:06 +0100 Subject: [PATCH 8/8] eddn/fsssignaldiscovered: Misc fixups * Need to remove `event`, `horizons` and `odyssey` per signal. * It's lower case `horizons` and `odyssey` in a(n augmented) journal event. * It's `event`, not `entry` that `export_journal_entry()` will look for. --- plugins/eddn.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 2c8e8916..3b1323fb 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -1387,20 +1387,23 @@ class EDDN: logger.trace_if("plugin.eddn.fsssignaldiscovered", "USSType is $USS_Type_MissionTarget;, dropping") continue - # Remove any `TimeRemaining` (USS) or `SystemAddress` keys + # Remove any key/values that shouldn't be there per signal + s.pop('event', None) + s.pop('horizons', None) + s.pop('odyssey', None) s.pop('TimeRemaining', None) s.pop('SystemAddress', None) msg['message']['signals'].append(s) # `horizons` and `odyssey` augmentations - msg['message']['horizons'] = entry['Horizons'] - msg['message']['odyssey'] = entry['Odyssey'] + msg['message']['horizons'] = entry['horizons'] + msg['message']['odyssey'] = entry['odyssey'] logger.trace_if("plugin.eddn.fsssignaldiscovered", f"FSSSignalDiscovered batch is {json.dumps(msg)}") # Fake an 'entry' as it's only there for some "should we send replay?" checks in the called function. - this.eddn.export_journal_entry(cmdr, {'entry': 'send_fsssignaldiscovered'}, msg) + this.eddn.export_journal_entry(cmdr, {'event': 'send_fsssignaldiscovered'}, msg) self.fss_signals = [] return None