From fc34d023b6db4255504d16e7d4317caccb695003 Mon Sep 17 00:00:00 2001 From: Athanasius <github@miggy.org> Date: Sun, 17 Oct 2021 14:10:30 +0100 Subject: [PATCH 1/3] EDDN: tracking_ui_update(): check if this UI bit actually active --- plugins/eddn.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index e6aa9431..841cbead 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -995,7 +995,10 @@ def plugin_app(parent: tk.Tk) -> Optional[tk.Frame]: def tracking_ui_update() -> None: - """Update the Tracking UI with current data.""" + """Update the Tracking UI with current data, if required.""" + if not config.eddn_tracking_ui: + return + this.ui_j_body_name['text'] = '≪None≫' if this.body_name is not None: this.ui_j_body_name['text'] = this.body_name From 5ae953bf4559d86541e20fe3bd882eee15cfaae5 Mon Sep 17 00:00:00 2001 From: Athanasius <github@miggy.org> Date: Sun, 17 Oct 2021 14:24:23 +0100 Subject: [PATCH 2/3] EDDN: Drop messages if EDDN says it doesn't know the schema Currently Live EDDN doesn't yet have the new schemas such as navroute, so will complain. Rather than leaving such messages in our EDDN replay queue and getting an error every time that is run, detect this error case and drop the messages. --- plugins/eddn.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/eddn.py b/plugins/eddn.py index 841cbead..9a783936 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -106,6 +106,11 @@ class EDDN: TIMEOUT = 10 # requests timeout MODULE_RE = re.compile(r'^Hpt_|^Int_|Armour_', re.IGNORECASE) CANONICALISE_RE = re.compile(r'\$(.+)_name;') + UNKNOWN_SCHEMA_RE = re.compile( + r"^FAIL: \[JsonValidationException\('Schema " + r"https://eddn.edcd.io/schemas/(?P<schema_name>.+)/(?P<schema_version>[0-9]+) is unknown, " + r"unable to validate.',\)\]$" + ) def __init__(self, parent: tk.Tk): self.parent: tk.Tk = parent @@ -210,6 +215,11 @@ class EDDN: logger.trace_if('plugin.eddn', "EDDN is still objecting to empty commodities data") return # We want to silence warnings otherwise + if unknown_schema := self.UNKNOWN_SCHEMA_RE.match(r.text): + logger.warning(f"EDDN doesn't (yet?) know about schema: {unknown_schema['schema_name']}" + f"/{unknown_schema['schema_version']}") + return # Pretend it went OK so this message isn't retried + logger.debug( f'''Status from POST wasn't OK: Status\t{r.status_code} From 7fa0576c85763205cd9be5f3ec873d06ff8cc1cf Mon Sep 17 00:00:00 2001 From: Athanasius <github@miggy.org> Date: Sun, 17 Oct 2021 14:41:25 +0100 Subject: [PATCH 3/3] EDDN: Keep 'unknown schema' messages in replaylog This still logs them, at DEBUG, which will get spammy as such messages accumulate. Uncommenting the: `# return # Pretend it went OK so this message isn't retried` at line 291 in EDDN.sendreplay(), in the: `except requests.exceptions.HTTPError as e:` block would cause them to not stay in the replaylog. --- plugins/eddn.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 9a783936..66956c48 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -215,19 +215,15 @@ class EDDN: logger.trace_if('plugin.eddn', "EDDN is still objecting to empty commodities data") return # We want to silence warnings otherwise - if unknown_schema := self.UNKNOWN_SCHEMA_RE.match(r.text): - logger.warning(f"EDDN doesn't (yet?) know about schema: {unknown_schema['schema_name']}" - f"/{unknown_schema['schema_version']}") - return # Pretend it went OK so this message isn't retried - - logger.debug( - f'''Status from POST wasn't OK: + if not self.UNKNOWN_SCHEMA_RE.match(r.text): + logger.debug( + f'''Status from POST wasn't OK: Status\t{r.status_code} URL\t{r.url} Headers\t{r.headers} Content:\n{r.text} Msg:\n{msg}''' - ) + ) r.raise_for_status() @@ -289,7 +285,13 @@ Msg:\n{msg}''' # in question out of replaylog, else we'll keep retrying a bad message # forever. except requests.exceptions.HTTPError as e: - status['text'] = self.http_error_to_log(e) + if unknown_schema := self.UNKNOWN_SCHEMA_RE.match(e.response.text): + logger.debug(f"EDDN doesn't (yet?) know about schema: {unknown_schema['schema_name']}" + f"/{unknown_schema['schema_version']}") + # return # Pretend it went OK so this message isn't retried + + else: + status['text'] = self.http_error_to_log(e) except requests.exceptions.RequestException as e: logger.debug('Failed sending', exc_info=e)