mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-06 10:23:06 +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:
|
if args.force_localserver_for_auth:
|
||||||
config.set_auth_force_localserver()
|
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.
|
Handle any edmc:// auth callback, else foreground existing window.
|
||||||
|
|
||||||
:returns: True if we are the single instance, else False.
|
|
||||||
"""
|
"""
|
||||||
logger.trace('Begin...')
|
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>
|
# Ref: <https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumwindows>
|
||||||
EnumWindows(enumwindowsproc, 0)
|
EnumWindows(enumwindowsproc, 0)
|
||||||
|
|
||||||
return False # Another instance is running
|
return
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def already_running_popup():
|
def already_running_popup():
|
||||||
"""Create the "already running" popup."""
|
"""Create the "already running" popup."""
|
||||||
@ -192,17 +188,18 @@ if __name__ == '__main__': # noqa: C901
|
|||||||
journal_lock = JournalLock()
|
journal_lock = JournalLock()
|
||||||
locked = journal_lock.obtain_lock()
|
locked = journal_lock.obtain_lock()
|
||||||
|
|
||||||
if journal_lock.journal_dir_lockfile:
|
handle_edmc_callback_or_foregrounding()
|
||||||
if not no_other_instance_running():
|
|
||||||
# There's a copy already running.
|
|
||||||
|
|
||||||
logger.info("An EDMarketConnector.exe process was already running, exiting.")
|
if not locked:
|
||||||
|
# There's a copy already running.
|
||||||
|
|
||||||
# To be sure the user knows, we need a popup
|
logger.info("An EDMarketConnector.exe process was already running, exiting.")
|
||||||
already_running_popup()
|
|
||||||
# If the user closes the popup with the 'X', not the 'OK' button we'll
|
# To be sure the user knows, we need a popup
|
||||||
# reach here.
|
already_running_popup()
|
||||||
sys.exit(0)
|
# If the user closes the popup with the 'X', not the 'OK' button we'll
|
||||||
|
# reach here.
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
# Now that we're sure we're the only instance running we can truncate the logfile
|
# Now that we're sure we're the only instance running we can truncate the logfile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user