mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-18 18:07:37 +03:00
Refactor old no_other_instance_running() into handle_edmc_callback_or_foregrounding()
The actual duplicate process checks *used* to be done in this function, but no longer are. Instead it's now specifically performing the "is this an edmc:// auth callback?" check, including the foreground of the extant process if needs be.
This commit is contained in:
parent
f3ef653a8d
commit
e430c3b350
@ -71,11 +71,9 @@ if __name__ == '__main__': # noqa: C901
|
||||
if args.force_localserver_for_auth:
|
||||
config.set_auth_force_localserver()
|
||||
|
||||
def no_other_instance_running() -> bool: # noqa: CCR001
|
||||
def handle_edmc_callback_or_foregrounding(): # noqa: CCR001
|
||||
"""
|
||||
Ensure only one copy of the app is running for the configured journal directory.
|
||||
|
||||
:returns: True if we are the single instance, else False.
|
||||
Handle any edmc:// auth callback, else foreground existing window.
|
||||
"""
|
||||
logger.trace('Begin...')
|
||||
|
||||
@ -162,9 +160,7 @@ if __name__ == '__main__': # noqa: C901
|
||||
# Ref: <https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumwindows>
|
||||
EnumWindows(enumwindowsproc, 0)
|
||||
|
||||
return False # Another instance is running
|
||||
|
||||
return True
|
||||
return
|
||||
|
||||
def already_running_popup():
|
||||
"""Create the "already running" popup."""
|
||||
@ -192,8 +188,9 @@ if __name__ == '__main__': # noqa: C901
|
||||
journal_lock = JournalLock()
|
||||
locked = journal_lock.obtain_lock()
|
||||
|
||||
if journal_lock.journal_dir_lockfile:
|
||||
if not no_other_instance_running():
|
||||
handle_edmc_callback_or_foregrounding()
|
||||
|
||||
if not locked:
|
||||
# There's a copy already running.
|
||||
|
||||
logger.info("An EDMarketConnector.exe process was already running, exiting.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user