From a6762755a0b0b685b9463ec77bc79eeaca4d57f8 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 10 Jul 2019 10:12:54 +0200 Subject: [PATCH] Minor updating system enhancements --- src/CNIRevelator.py | 4 ++-- src/updater.py | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/CNIRevelator.py b/src/CNIRevelator.py index 860c2a2..b586b9e 100644 --- a/src/CNIRevelator.py +++ b/src/CNIRevelator.py @@ -40,7 +40,7 @@ launcherWindow = ihm.launcherWindowCur ## MAIN FUNCTION OF CNIREVELATOR def main(): - + import CNI_pytesseract as pytesseract try: os.environ['PATH'] = CST_FOLDER + 'Tesseract-OCR4\\' @@ -52,7 +52,7 @@ def main(): text = 'Tesseract version ' + str(tesser_version) + ' Licensed Apache 2004 successfully initiated\n' main_w.montext(text) main_w.montext('\n\nEntrez la première ligne de MRZ svp \n') - + if CST_CHANGELOG.isOn: showinfo('Changelog : résumé de mise à jour', ('Version du logiciel : ' + CST_VER + ' ' + CST_TYPE + ' Revision ' + CST_REV + '\n\n' + CST_CHANGELOG.text), parent=main_w) logger.info('main() : **** Launching App_main() ****') diff --git a/src/updater.py b/src/updater.py index 80b0f40..4f14fd2 100644 --- a/src/updater.py +++ b/src/updater.py @@ -131,7 +131,8 @@ def batch(): getTheUpdate = downloader.newdownload(credentials, finalurl, globs.CNIRFolder + '\\..\\CNIPackage.zip').download() - # BUF_SIZE is totally arbitrary, change for your app! + launcherWindow.mainCanvas.itemconfigure(launcherWindow.msg, text=('Verifying download...')) + BUF_SIZE = 65536 # lets read stuff in 64kb chunks! sha1 = hashlib.sha1() @@ -151,17 +152,35 @@ def batch(): return False # And now unzip and launch + logfile.printdbg("Make place") + launcherWindow.mainCanvas.itemconfigure(launcherWindow.msg, text=('Preparing installation...')) + try: + shutil.rmtree(globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full) + 'temp') + shutil.rmtree(globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full)) + except: + pass + logfile.printdbg("Unzipping the package") + launcherWindow.mainCanvas.itemconfigure(launcherWindow.msg, text=('Installing the updates')) zip_ref = zipfile.ZipFile(globs.CNIRFolder + '\\..\\CNIPackage.zip', 'r') - zip_ref.extractall(globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full)) + zip_ref.extractall(globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full) + 'temp') zip_ref.close() - logfile.printdbg(globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full) + '\\CNIRevelator.exe') + shutil.copytree(globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full) + 'temp\\CNIRevelator', globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full)) + shutil.rmtree(globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full) + 'temp') + + logfile.printdbg('Extracted :' + globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full) + '\\CNIRevelator.exe') + + launcherWindow.mainCanvas.itemconfigure(launcherWindow.msg, text=('Success !')) args = [globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full) + '\\CNIRevelator.exe', globs.CNIRFolder] subprocess.run(args) - - return True + + launcherWindow.mainCanvas.itemconfigure(launcherWindow.msg, text=('Launched the new process.')) + + launcherWindow.destroy() + sys.exit(0) + return ## Main Function def umain():