diff --git a/plugins/eddn.py b/plugins/eddn.py index 3526085e..a5d91fee 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -81,18 +81,14 @@ class EDDN: # Try to open existing file self.replayfile = open(filename, 'r+', buffering=1) - except Exception: - if exists(filename): - raise # Couldn't open existing file - - else: - self.replayfile = open(filename, 'w+', buffering=1) # Create file + except FileNotFoundError: + self.replayfile = open(filename, 'w+', buffering=1) # Create file if sys.platform != 'win32': # open for writing is automatically exclusive on Windows lockf(self.replayfile, LOCK_EX | LOCK_NB) - except Exception as e: - logger.debug('Failed opening "replay.jsonl"', exc_info=e) + except Exception: + logger.exception('Failed opening "replay.jsonl"') if self.replayfile: self.replayfile.close() @@ -179,6 +175,9 @@ class EDDN: self.replaylog.pop(0) else: + # TODO: Check message against *current* relevant schema so we don't try + # to send an old message that's now invalid. + # Rewrite old schema name if msg['$schemaRef'].startswith('http://schemas.elite-markets.net/eddn/'): msg['$schemaRef'] = str(msg['$schemaRef']).replace( @@ -639,21 +638,21 @@ def journal_entry( # add mandatory StarSystem, StarPos and SystemAddress properties to Scan events if 'StarSystem' not in entry: if not system: - logger.warn("system is None, can't add StarSystem") + logger.warning("system is None, can't add StarSystem") return "system is None, can't add StarSystem" entry['StarSystem'] = system if 'StarPos' not in entry: if not this.coordinates: - logger.warn("this.coordinates is None, can't add StarPos") + logger.warning("this.coordinates is None, can't add StarPos") return "this.coordinates is None, can't add StarPos" entry['StarPos'] = list(this.coordinates) if 'SystemAddress' not in entry: if not this.systemaddress: - logger.warn("this.systemaddress is None, can't add SystemAddress") + logger.warning("this.systemaddress is None, can't add SystemAddress") return "this.systemaddress is None, can't add SystemAddress" entry['SystemAddress'] = this.systemaddress