From a101664f6e9e8e9c3a2b071be6b313fff0b9028f Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 11 Jul 2019 10:30:12 +0200 Subject: [PATCH] Finished work on Update System --- src/test.py | 15 +++++++++++++++ src/updater.py | 17 ++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 src/test.py diff --git a/src/test.py b/src/test.py new file mode 100644 index 0000000..6f76b78 --- /dev/null +++ b/src/test.py @@ -0,0 +1,15 @@ +import globs +import psutil +import os + +for process in psutil.process_iter(): + if process.name() == 'CNIRevelator.exe': + print('Process found. Command line: {}'.format(process.cmdline())) + if True: + print(process.pid) + + continue + else: + print('Terminating process !') + #process.terminate() + break \ No newline at end of file diff --git a/src/updater.py b/src/updater.py index 4221a1c..48586f0 100644 --- a/src/updater.py +++ b/src/updater.py @@ -140,6 +140,7 @@ def batch(): launcherWindow.printmsg('Verifying download...') + # CHECKSUM BUF_SIZE = 65536 # lets read stuff in 64kb chunks! sha1 = hashlib.sha1() @@ -218,16 +219,18 @@ def umain(): launcherWindow.printmsg('Fail :{}'.format(e)) try: for process in psutil.process_iter(): - logfile.printdbg(str(process.cmdline())) - # if process.cmdline() == ['CNIRevelator.exe', '']: - # print('Process found. Terminating it.') - # process.terminate() - # break - else: - logfile.printerr('Process not found') + if process.name() == 'CNIRevelator.exe': + logfile.printdbg('Process found. Command line: {}'.format(process.cmdline())) + if process.pid == os.getpid(): + logfile.printdbg("Don't touch us ! {} = {}".format(process.pid, os.getpid())) + else: + logfile.printdbg('Terminating process !') + process.terminate() + break except Exception as e: logfile.printerr(str(e)) launcherWindow.printmsg('Fail :{}'.format(e)) + launcherWindow.printmsg('Starting...') try: try: