From 377eef9c2bb3a37180dcc591a0d871eef618b5e9 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 18 Jan 2021 21:15:52 +0000 Subject: [PATCH] config import needs to be up top for now & misc * The end of the win32/else conditional was identical, so only do that write to the successfully locked file in one place. * No need to go out of `__main__` only to go straight back in. --- EDMarketConnector.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 2c9a83bd..687436a1 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -15,6 +15,7 @@ from sys import platform from time import localtime, strftime, time from typing import TYPE_CHECKING +from config import appversion, appversion_nobuild, config, copyright from constants import applongname, appname, protocolhandler_redirect # config will now cause an appname logger to be set up, so we need the @@ -41,7 +42,6 @@ if __name__ == '__main__': args = parser.parse_args() -if __name__ == "__main__": journal_dir: str = config.get('journaldir') or config.default_journal_dir # This must be at top level to guarantee the file handle doesn't go out # of scope and get cleaned up, removing the lock with it. @@ -69,8 +69,6 @@ if __name__ == "__main__": print(f"Exception: Couldn't lock journal directory \"{journal_dir}\", assuming another process running\n{e!r}") return False - journal_dir_lockfile.write(f"Path: {journal_dir}\nPID: {os_getpid()}\n") - else: print('no_other_instance_running(): NOT win32, using fcntl') try: @@ -86,7 +84,7 @@ if __name__ == "__main__": print(f"Exception: Couldn't lock journal directory \"{journal_dir}\", assuming another process running\n{e!r}") return False - journal_dir_lockfile.write(f"Path: {journal_dir}\nPID: {os_getpid()}\n") + journal_dir_lockfile.write(f"Path: {journal_dir}\nPID: {os_getpid()}\n") print('no_other_instance_running(): Done') return True @@ -145,9 +143,6 @@ if __name__ == "__main__": sys.stdout = sys.stderr = open(join(tempfile.gettempdir(), f'{appname}.log'), mode='wt', buffering=1) # TODO: Test: Make *sure* this redirect is working, else py2exe is going to cause an exit popup -# isort: off -from config import appversion, appversion_nobuild, config, copyright -# isort: on from EDMCLogging import edmclogger, logger, logging