1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

config: Make config.shutting_down() a property, and change 'callers'

This commit is contained in:
Athanasius 2021-01-11 16:54:09 +00:00
parent 111f445cac
commit 462cd25312
10 changed files with 16 additions and 15 deletions

View File

@ -182,6 +182,7 @@ class Config(object):
def set_shutdown(self):
self.__in_shutdown = True
@property
def shutting_down(self) -> bool:
return self.__in_shutdown

View File

@ -115,9 +115,9 @@ class Dashboard(FileSystemEventHandler):
# Can be called either in watchdog thread or, if polling, in main thread.
def process(self, logfile=None):
if config.shutting_down():
if config.shutting_down:
return
try:
with open(join(self.currentdir, 'Status.json'), 'rb') as h:
data = h.read().strip()

View File

@ -92,7 +92,7 @@ if platform == 'darwin':
self.observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, self._handler)
def _poll(self):
if config.shutting_down():
if config.shutting_down:
return
# No way of signalling to Tkinter from within the callback handler block that doesn't
@ -127,7 +127,7 @@ if platform == 'darwin':
self.acquire_state = HotkeyMgr.ACQUIRE_INACTIVE
def _acquire_poll(self):
if config.shutting_down():
if config.shutting_down:
return
# No way of signalling to Tkinter from within the monkey-patched event handler that doesn't
@ -323,7 +323,7 @@ elif platform == 'win32':
while GetMessage(ctypes.byref(msg), None, 0, 0) != 0:
if msg.message == WM_HOTKEY:
if config.getint('hotkey_always') or WindowTitle(GetForegroundWindow()).startswith('Elite - Dangerous'):
if not config.shutting_down():
if not config.shutting_down:
self.root.event_generate('<<Invoke>>', when="tail")
else:
# Pass the key on

View File

@ -337,7 +337,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.event_queue.append(line)
if self.event_queue:
if not config.shutting_down():
if not config.shutting_down:
self.root.event_generate('<<JournalEvent>>', when="tail")
log_pos = loghandle.tell()
@ -356,7 +356,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
'{{ "timestamp":"{}", "event":"ShutDown" }}'.format(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()))
)
if not config.shutting_down():
if not config.shutting_down:
self.root.event_generate('<<JournalEvent>>', when="tail")
self.game_was_running = False

View File

@ -372,7 +372,7 @@ def show_error(err):
.. versionadded:: 2.3.7
"""
if config.shutting_down():
if config.shutting_down:
logger.info(f'Called during shutdown: "{str(err)}"')
return

View File

@ -599,7 +599,7 @@ def worker() -> None:
# Update main window's system status
this.lastlookup = r
if not config.shutting_down():
if not config.shutting_down:
# calls update_status in main thread
this.system_link.event_generate('<<EDSMStatus>>', when="tail")

View File

@ -1291,14 +1291,14 @@ def send_data(url: str, data: Mapping[str, Any]) -> bool:
):
this.lastlocation = reply_event.get('eventData', {})
if not config.shutting_down():
if not config.shutting_down:
# calls update_location in main thread
this.system_link.event_generate('<<InaraLocation>>', when="tail")
elif data_event['eventName'] in ['addCommanderShip', 'setCommanderShip']:
this.lastship = reply_event.get('eventData', {})
if not config.shutting_down():
if not config.shutting_down:
# calls update_ship in main thread
this.system_link.event_generate('<<InaraShip>>', when="tail")

View File

@ -1157,5 +1157,5 @@ class PreferencesDialog(tk.Toplevel):
except Exception:
AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True})
if not config.shutting_down():
if not config.shutting_down:
self.parent.event_generate('<<Quit>>', when="tail")

View File

@ -33,7 +33,7 @@ class GenericProtocolHandler(object):
def event(self, url):
self.lastpayload = url
if not config.shutting_down():
if not config.shutting_down:
self.master.event_generate('<<CompanionAuthEvent>>', when="tail")

View File

@ -40,7 +40,7 @@ class Updater(object):
Receive (Win)Sparkle shutdown request and send it to parent.
:rtype: None
"""
if not config.shutting_down():
if not config.shutting_down:
self.root.event_generate('<<Quit>>', when="tail")
def use_internal(self) -> bool:
@ -209,4 +209,4 @@ class Updater(object):
:return: None
"""
pass
pass