mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
EDMarketConnector: Care about "are we already running?" check
1) Don't log in this check, we're a different process. 2) But we've stomped the plain log file already! 3) Python 3.8.6 seems to not like sys.exit(0) from that ctypes code, so `return False` instead and check the return from EnumWindows().
This commit is contained in:
parent
404f1fa641
commit
3a57128e28
@ -1357,8 +1357,8 @@ def enforce_single_instance() -> None: # noqa: CCR001
|
||||
and GetProcessHandleFromHwnd(window_handle):
|
||||
# If GetProcessHandleFromHwnd succeeds then the app is already running as this user
|
||||
if len(sys.argv) > 1 and sys.argv[1].startswith(protocolhandler.redirect):
|
||||
logger.debug('Browser invoked us directly with auth response. '
|
||||
'Forwarding the response to the other app instance.')
|
||||
# logger.debug('Browser invoked us directly with auth response. '
|
||||
# 'Forwarding the response to the other app instance.')
|
||||
CoInitializeEx(0, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
|
||||
# Wait for it to be responsive to avoid ShellExecute recursing
|
||||
ShowWindow(window_handle, SW_RESTORE)
|
||||
@ -1368,12 +1368,13 @@ def enforce_single_instance() -> None: # noqa: CCR001
|
||||
ShowWindowAsync(window_handle, SW_RESTORE)
|
||||
SetForegroundWindow(window_handle)
|
||||
|
||||
logger.info(f'A running {applongname} process was found, exiting.')
|
||||
sys.exit(0)
|
||||
# logger.info(f'A running {applongname} process was found, exiting.')
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
EnumWindows(enumwindowsproc, 0)
|
||||
if not EnumWindows(enumwindowsproc, 0):
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def test_logging() -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user