From ca4214fff8871b01c82a4c7fd93be8f2e94b716f Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 28 Sep 2020 12:26:09 +0100 Subject: [PATCH] EDDN: Catch and log 'we tried to send empty market'. Very tight check on this to be sure we don't ignore other errors. r.status_code == 400 # Not a different code $schemaRef == commodities The message had empty commodities list r.text == expected return from EDDN Gateway --- plugins/eddn.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 7809cdd9..e7e576ad 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -140,19 +140,22 @@ class EDDN: r = self.session.post(self.UPLOAD, data=json.dumps(to_send), timeout=self.TIMEOUT) if r.status_code != requests.codes.ok: + + # Check if EDDN is still objecting to an empty commodities list + if r.status_code == 400 \ + and msg['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' \ + and msg['message']['commodities'] == [] \ + and r.text == "FAIL: []": + logger.trace("EDDN is still objecting to empty commodities data") + return # We want to silence warnings otherwise + 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}''') - - # Check if EDDN is still objecting to an empty commodities list - if r.status_code == 400 \ - and msg['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' \ - and this.commodities == [] \ - and r.text == "FAIL: []": - logger.trace("EDDN is still objecting to empty commodities data") +Msg:\n{msg}''' + ) r.raise_for_status()