mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-15 00:30:33 +03:00
config: Make config.shutting_down() a property, and change 'callers'
This commit is contained in:
parent
111f445cac
commit
462cd25312
@ -182,6 +182,7 @@ class Config(object):
|
|||||||
def set_shutdown(self):
|
def set_shutdown(self):
|
||||||
self.__in_shutdown = True
|
self.__in_shutdown = True
|
||||||
|
|
||||||
|
@property
|
||||||
def shutting_down(self) -> bool:
|
def shutting_down(self) -> bool:
|
||||||
return self.__in_shutdown
|
return self.__in_shutdown
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ class Dashboard(FileSystemEventHandler):
|
|||||||
|
|
||||||
# Can be called either in watchdog thread or, if polling, in main thread.
|
# Can be called either in watchdog thread or, if polling, in main thread.
|
||||||
def process(self, logfile=None):
|
def process(self, logfile=None):
|
||||||
if config.shutting_down():
|
if config.shutting_down:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(join(self.currentdir, 'Status.json'), 'rb') as h:
|
with open(join(self.currentdir, 'Status.json'), 'rb') as h:
|
||||||
data = h.read().strip()
|
data = h.read().strip()
|
||||||
|
@ -92,7 +92,7 @@ if platform == 'darwin':
|
|||||||
self.observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, self._handler)
|
self.observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, self._handler)
|
||||||
|
|
||||||
def _poll(self):
|
def _poll(self):
|
||||||
if config.shutting_down():
|
if config.shutting_down:
|
||||||
return
|
return
|
||||||
|
|
||||||
# No way of signalling to Tkinter from within the callback handler block that doesn't
|
# 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
|
self.acquire_state = HotkeyMgr.ACQUIRE_INACTIVE
|
||||||
|
|
||||||
def _acquire_poll(self):
|
def _acquire_poll(self):
|
||||||
if config.shutting_down():
|
if config.shutting_down:
|
||||||
return
|
return
|
||||||
|
|
||||||
# No way of signalling to Tkinter from within the monkey-patched event handler that doesn't
|
# 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:
|
while GetMessage(ctypes.byref(msg), None, 0, 0) != 0:
|
||||||
if msg.message == WM_HOTKEY:
|
if msg.message == WM_HOTKEY:
|
||||||
if config.getint('hotkey_always') or WindowTitle(GetForegroundWindow()).startswith('Elite - Dangerous'):
|
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")
|
self.root.event_generate('<<Invoke>>', when="tail")
|
||||||
else:
|
else:
|
||||||
# Pass the key on
|
# Pass the key on
|
||||||
|
@ -337,7 +337,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
self.event_queue.append(line)
|
self.event_queue.append(line)
|
||||||
|
|
||||||
if self.event_queue:
|
if self.event_queue:
|
||||||
if not config.shutting_down():
|
if not config.shutting_down:
|
||||||
self.root.event_generate('<<JournalEvent>>', when="tail")
|
self.root.event_generate('<<JournalEvent>>', when="tail")
|
||||||
|
|
||||||
log_pos = loghandle.tell()
|
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()))
|
'{{ "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.root.event_generate('<<JournalEvent>>', when="tail")
|
||||||
|
|
||||||
self.game_was_running = False
|
self.game_was_running = False
|
||||||
|
2
plug.py
2
plug.py
@ -372,7 +372,7 @@ def show_error(err):
|
|||||||
.. versionadded:: 2.3.7
|
.. versionadded:: 2.3.7
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if config.shutting_down():
|
if config.shutting_down:
|
||||||
logger.info(f'Called during shutdown: "{str(err)}"')
|
logger.info(f'Called during shutdown: "{str(err)}"')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ def worker() -> None:
|
|||||||
# Update main window's system status
|
# Update main window's system status
|
||||||
this.lastlookup = r
|
this.lastlookup = r
|
||||||
|
|
||||||
if not config.shutting_down():
|
if not config.shutting_down:
|
||||||
# calls update_status in main thread
|
# calls update_status in main thread
|
||||||
this.system_link.event_generate('<<EDSMStatus>>', when="tail")
|
this.system_link.event_generate('<<EDSMStatus>>', when="tail")
|
||||||
|
|
||||||
|
@ -1291,14 +1291,14 @@ def send_data(url: str, data: Mapping[str, Any]) -> bool:
|
|||||||
):
|
):
|
||||||
this.lastlocation = reply_event.get('eventData', {})
|
this.lastlocation = reply_event.get('eventData', {})
|
||||||
|
|
||||||
if not config.shutting_down():
|
if not config.shutting_down:
|
||||||
# calls update_location in main thread
|
# calls update_location in main thread
|
||||||
this.system_link.event_generate('<<InaraLocation>>', when="tail")
|
this.system_link.event_generate('<<InaraLocation>>', when="tail")
|
||||||
|
|
||||||
elif data_event['eventName'] in ['addCommanderShip', 'setCommanderShip']:
|
elif data_event['eventName'] in ['addCommanderShip', 'setCommanderShip']:
|
||||||
this.lastship = reply_event.get('eventData', {})
|
this.lastship = reply_event.get('eventData', {})
|
||||||
|
|
||||||
if not config.shutting_down():
|
if not config.shutting_down:
|
||||||
# calls update_ship in main thread
|
# calls update_ship in main thread
|
||||||
this.system_link.event_generate('<<InaraShip>>', when="tail")
|
this.system_link.event_generate('<<InaraShip>>', when="tail")
|
||||||
|
|
||||||
|
2
prefs.py
2
prefs.py
@ -1157,5 +1157,5 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
except Exception:
|
except Exception:
|
||||||
AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True})
|
AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True})
|
||||||
|
|
||||||
if not config.shutting_down():
|
if not config.shutting_down:
|
||||||
self.parent.event_generate('<<Quit>>', when="tail")
|
self.parent.event_generate('<<Quit>>', when="tail")
|
||||||
|
@ -33,7 +33,7 @@ class GenericProtocolHandler(object):
|
|||||||
def event(self, url):
|
def event(self, url):
|
||||||
self.lastpayload = url
|
self.lastpayload = url
|
||||||
|
|
||||||
if not config.shutting_down():
|
if not config.shutting_down:
|
||||||
self.master.event_generate('<<CompanionAuthEvent>>', when="tail")
|
self.master.event_generate('<<CompanionAuthEvent>>', when="tail")
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class Updater(object):
|
|||||||
Receive (Win)Sparkle shutdown request and send it to parent.
|
Receive (Win)Sparkle shutdown request and send it to parent.
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
if not config.shutting_down():
|
if not config.shutting_down:
|
||||||
self.root.event_generate('<<Quit>>', when="tail")
|
self.root.event_generate('<<Quit>>', when="tail")
|
||||||
|
|
||||||
def use_internal(self) -> bool:
|
def use_internal(self) -> bool:
|
||||||
@ -209,4 +209,4 @@ class Updater(object):
|
|||||||
|
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user