From 75e0a85a86448bd6b8a784d9eb1f90a167b16ed8 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 11 Jul 2019 16:04:18 +0200 Subject: [PATCH] Correcting the Shutdown System --- src/CNIRevelator.py | 18 ++++++++---------- src/updater.py | 7 +++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/CNIRevelator.py b/src/CNIRevelator.py index 6504a17..f944fb2 100644 --- a/src/CNIRevelator.py +++ b/src/CNIRevelator.py @@ -34,11 +34,14 @@ import launcher # launcher.py import updater # updater.py import globs # globs.py import pytesseract # pytesseract.py +import logger # logger.py + +# Global handler +logfile = logger.logCur ## MAIN FUNCTION OF CNIREVELATOR def main(): - import logger # logger.py - logfile = logger.logCur + logfile.printdbg('*** CNIRevelator LOGFILE. Hello World ! ***') @@ -70,7 +73,7 @@ try: launcherThread = threading.Thread(target=updater.umain, daemon=False) launcher.lmain(launcherThread) except Exception: - sys.exit(1) + updater.exitProcess(1) if updater.UPDATE_IS_MADE: # Launch app ! @@ -83,15 +86,10 @@ if updater.UPDATE_IS_MADE: time.sleep(3) continue break - sys.exit(0) + updater.exitProcess(0) # Here we go ! try: main() except Exception: - sys.exit(1) - -# Quit totally without remain in memory -for process in psutil.process_iter(): - if process.pid == os.getpid(): - process.terminate() \ No newline at end of file + updater.exitProcess(1) \ No newline at end of file diff --git a/src/updater.py b/src/updater.py index f284aae..08bc11b 100644 --- a/src/updater.py +++ b/src/updater.py @@ -63,6 +63,13 @@ def createShortcut(path, target='', wDir='', icon=''): def spawnProcess(args, cd): subprocess.Popen(args, close_fds=True, cwd=cd, creationflags=subprocess.DETACHED_PROCESS) +def exitProcess(arg): + # Quit totally without remain in memory + for process in psutil.process_iter(): + if process.pid == os.getpid(): + process.terminate() + sys.exit(arg) + ## Main Batch Function def batch():