1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-06 10:23:06 +03:00

Avoid spurious errors in debug log when polling

This commit is contained in:
Jonathan Harris 2018-03-04 18:14:01 +00:00
parent fdd770fe64
commit daf53de57d

View File

@ -118,10 +118,13 @@ class Dashboard(FileSystemEventHandler):
def process(self, logfile=None): def process(self, logfile=None):
try: try:
with open(join(self.currentdir, 'Status.json'), 'rb') as h: with open(join(self.currentdir, 'Status.json'), 'rb') as h:
entry = json.load(h) data = h.read().strip()
if data: # Can be empty if polling while the file is being re-written
entry = json.loads(data)
# Status file is shared between beta and live. So filter out status not in this game session. # Status file is shared between beta and live. So filter out status not in this game session.
if timegm(time.strptime(entry['timestamp'], '%Y-%m-%dT%H:%M:%SZ')) >= self.session_start and self.status != entry: if (timegm(time.strptime(entry['timestamp'], '%Y-%m-%dT%H:%M:%SZ')) >= self.session_start and
self.status != entry):
self.status = entry self.status = entry
self.root.event_generate('<<DashboardEvent>>', when="tail") self.root.event_generate('<<DashboardEvent>>', when="tail")
except: except: