From 9869cd58e8ba38dde657b00c03e161ffbb5730c0 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Thu, 17 Aug 2017 16:31:51 +0100 Subject: [PATCH] Handle new Journal filename in Beta --- monitor.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/monitor.py b/monitor.py index 8304b27d..27ad75ce 100644 --- a/monitor.py +++ b/monitor.py @@ -164,7 +164,8 @@ class EDLogs(FileSystemEventHandler): # Latest pre-existing logfile - e.g. if E:D is already running. Assumes logs sort alphabetically. # Do this before setting up the observer in case the journal directory has gone away try: - logfiles = sorted([x for x in listdir(self.currentdir) if x.startswith('Journal.') and x.endswith('.log')]) + logfiles = sorted([x for x in listdir(self.currentdir) if x.startswith('Journal') and x.endswith('.log')], + key=lambda x: x.split('.')[1:]) self.logfile = logfiles and join(self.currentdir, logfiles[-1]) or None except: self.logfile = None @@ -224,7 +225,7 @@ class EDLogs(FileSystemEventHandler): def on_created(self, event): # watchdog callback, e.g. client (re)started. - if not event.is_directory and basename(event.src_path).startswith('Journal.') and basename(event.src_path).endswith('.log'): + if not event.is_directory and basename(event.src_path).startswith('Journal') and basename(event.src_path).endswith('.log'): self.logfile = event.src_path def worker(self): @@ -263,7 +264,8 @@ class EDLogs(FileSystemEventHandler): else: # Poll try: - logfiles = sorted([x for x in listdir(self.currentdir) if x.startswith('Journal.') and x.endswith('.log')]) + logfiles = sorted([x for x in listdir(self.currentdir) if x.startswith('Journal') and x.endswith('.log')], + key=lambda x: x.split('.')[1:]) newlogfile = logfiles and join(self.currentdir, logfiles[-1]) or None except: if __debug__: print_exc()