mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
Replaced modulo formatters with .format formatters
This commit is contained in:
parent
05e6d49880
commit
ed45d59af1
18
monitor.py
18
monitor.py
@ -160,8 +160,8 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
self.observed = self.observer.schedule(self, self.currentdir)
|
self.observed = self.observer.schedule(self, self.currentdir)
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
print('%s Journal "%s"' % (polling and 'Polling' or 'Monitoring', self.currentdir))
|
print('{} Journal {!r}'.format(polling and 'Polling' or 'Monitoring', self.currentdir))
|
||||||
print('Start logfile "%s"' % self.logfile)
|
print('Start logfile {!r}'.format(self.logfile))
|
||||||
|
|
||||||
if not self.running():
|
if not self.running():
|
||||||
self.thread = threading.Thread(target=self.worker, name='Journal worker')
|
self.thread = threading.Thread(target=self.worker, name='Journal worker')
|
||||||
@ -232,7 +232,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
if __debug__:
|
if __debug__:
|
||||||
print('Invalid journal entry "%s"' % repr(line))
|
print('Invalid journal entry {!r}'.format(line))
|
||||||
|
|
||||||
log_pos = loghandle.tell()
|
log_pos = loghandle.tell()
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
log_pos = 0
|
log_pos = 0
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
print('New logfile "%s"' % logfile)
|
print('New logfile {!r}'.format(logfile))
|
||||||
|
|
||||||
if logfile:
|
if logfile:
|
||||||
loghandle.seek(0, SEEK_END) # required to make macOS notice log change over SMB
|
loghandle.seek(0, SEEK_END) # required to make macOS notice log change over SMB
|
||||||
@ -330,7 +330,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
if self.game_was_running:
|
if self.game_was_running:
|
||||||
if not self.game_running():
|
if not self.game_running():
|
||||||
self.event_queue.append(
|
self.event_queue.append(
|
||||||
'{ "timestamp":"%s", "event":"ShutDown" }' % strftime('%Y-%m-%dT%H:%M:%SZ', gmtime())
|
'{{ "timestamp":"{}", "event":"ShutDown" }}'.format(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()))
|
||||||
)
|
)
|
||||||
|
|
||||||
self.root.event_generate('<<JournalEvent>>', when="tail")
|
self.root.event_generate('<<JournalEvent>>', when="tail")
|
||||||
@ -747,7 +747,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
return entry
|
return entry
|
||||||
except Exception:
|
except Exception:
|
||||||
if __debug__:
|
if __debug__:
|
||||||
print('Invalid journal entry "%s"' % repr(line))
|
print('Invalid journal entry {!r}'.format(line))
|
||||||
print_exc()
|
print_exc()
|
||||||
|
|
||||||
return {'event': None}
|
return {'event': None}
|
||||||
@ -804,7 +804,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
|
|
||||||
elif self.live and entry['event'] == 'Music' and entry.get('MusicTrack') == 'MainMenu':
|
elif self.live and entry['event'] == 'Music' and entry.get('MusicTrack') == 'MainMenu':
|
||||||
self.event_queue.append(
|
self.event_queue.append(
|
||||||
'{ "timestamp":"%s", "event":"ShutDown" }' % strftime('%Y-%m-%dT%H:%M:%SZ', gmtime())
|
'{{ "timestamp":"{}", "event":"ShutDown" }}'.format(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()))
|
||||||
)
|
)
|
||||||
|
|
||||||
return entry
|
return entry
|
||||||
@ -897,7 +897,9 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
return # same as last time - don't write
|
return # same as last time - don't write
|
||||||
|
|
||||||
# Write
|
# Write
|
||||||
filename = join(config.get('outdir'), '%s.%s.txt' % (ship, strftime('%Y-%m-%dT%H.%M.%S', localtime(time()))))
|
filename = join(
|
||||||
|
config.get('outdir'), '{}.{}.txt'.format(ship, strftime('%Y-%m-%dT%H.%M.%S', localtime(time())))
|
||||||
|
)
|
||||||
with open(filename, 'wt') as h:
|
with open(filename, 'wt') as h:
|
||||||
h.write(string)
|
h.write(string)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user