mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
eddn: Straighten out replay.jsonl opening & minor cleanups.
* The logic for opening replay.jsonl, and detecting if the file was already there or not was tortured. No longer. * Changed a few logger.debug(..., exc_info=) to logger.exception(). * Changed all logger.warn() (deprecated) to logger.warning().
This commit is contained in:
parent
5d612822da
commit
48077f6a30
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user