From 462cd253129319d67e0b715e6b3f6cf17b511375 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 11 Jan 2021 16:54:09 +0000 Subject: [PATCH] config: Make config.shutting_down() a property, and change 'callers' --- config.py | 1 + dashboard.py | 4 ++-- hotkey.py | 6 +++--- monitor.py | 4 ++-- plug.py | 2 +- plugins/edsm.py | 2 +- plugins/inara.py | 4 ++-- prefs.py | 2 +- protocol.py | 2 +- update.py | 4 ++-- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/config.py b/config.py index 0ff7ae7e..76013029 100644 --- a/config.py +++ b/config.py @@ -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 diff --git a/dashboard.py b/dashboard.py index 68e828e5..4259dccb 100644 --- a/dashboard.py +++ b/dashboard.py @@ -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() diff --git a/hotkey.py b/hotkey.py index 5b3323b8..9b261ccc 100644 --- a/hotkey.py +++ b/hotkey.py @@ -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('<>', when="tail") else: # Pass the key on diff --git a/monitor.py b/monitor.py index 4901c3f2..f8d4a201 100644 --- a/monitor.py +++ b/monitor.py @@ -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('<>', 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('<>', when="tail") self.game_was_running = False diff --git a/plug.py b/plug.py index 98591a84..755fec1c 100644 --- a/plug.py +++ b/plug.py @@ -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 diff --git a/plugins/edsm.py b/plugins/edsm.py index a77de879..e9fbd46c 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -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('<>', when="tail") diff --git a/plugins/inara.py b/plugins/inara.py index 9aeef582..ac5d53f5 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -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('<>', 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('<>', when="tail") diff --git a/prefs.py b/prefs.py index 69f7140c..e9c3afab 100644 --- a/prefs.py +++ b/prefs.py @@ -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('<>', when="tail") diff --git a/protocol.py b/protocol.py index ea7bfaf6..7990b952 100644 --- a/protocol.py +++ b/protocol.py @@ -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('<>', when="tail") diff --git a/update.py b/update.py index 3b57fb9e..aa2a1a8f 100644 --- a/update.py +++ b/update.py @@ -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('<>', when="tail") def use_internal(self) -> bool: @@ -209,4 +209,4 @@ class Updater(object): :return: None """ - pass \ No newline at end of file + pass