diff --git a/src/updater.py b/src/updater.py index 940641b..8ae9948 100644 --- a/src/updater.py +++ b/src/updater.py @@ -207,18 +207,24 @@ def tessInstall(PATH, credentials): logfile.printdbg('Preparing download of Tesseract OCR 4...') getTesseract = downloader.newdownload(credentials, tesseracturl, PATH + '\\downloads\\TsrtPackage.zip', "Tesseract 4 OCR Module").download() - # Unzip Tesseract - logfile.printdbg("Unzipping the package") - launcherWindow.printmsg('Installing the updates') - zip_ref = zipfile.ZipFile(PATH + '\\downloads\\TsrtPackage.zip', 'r') - zip_ref.extractall(PATH) - zip_ref.close() - - # Cleanup try: - os.remove(UPATH + '\\downloads\\TsrtPackage.zip') + # Unzip Tesseract + logfile.printdbg("Unzipping the package") + launcherWindow.printmsg('Installing the updates') + zip_ref = zipfile.ZipFile(PATH + '\\downloads\\TsrtPackage.zip', 'r') + zip_ref.extractall(PATH) + zip_ref.close() + # Cleanup + try: + os.remove(UPATH + '\\downloads\\TsrtPackage.zip') + except: + pass + return True + except: - pass + return False + else: + return True ## Main Batch Function def batch(credentials): @@ -374,7 +380,6 @@ def umain(): try: # EXECUTING THE UPDATE BATCH success = batch(credentials) - tessInstall(globs.CNIRFolder, credentials) except Exception as e: logfile.printerr("An error occured on the thread : " + str(traceback.format_exc())) launcherWindow.printmsg('ERROR : ' + str(e)) @@ -388,9 +393,39 @@ def umain(): else: logfile.printerr("An error occured. No effective update !") launcherWindow.printmsg('An error occured. No effective update !') - time.sleep(2) + time.sleep(2) + launcherWindow.exit() + return 0 + + if UPDATE_IS_MADE: + launcherWindow.exit() + return 0 + except: + logfile.printerr("A FATAL ERROR OCCURED : " + str(traceback.format_exc())) launcherWindow.exit() - return 0 + sys.exit(2) + return 2 + + try: + try: + # INSTALLING TESSERACT OCR + success = tessInstall(globs.CNIRFolder, credentials) + except Exception as e: + logfile.printerr("An error occured on the thread : " + str(traceback.format_exc())) + launcherWindow.printmsg('ERROR : ' + str(e)) + time.sleep(3) + launcherWindow.exit() + return 1 + + if success: + logfile.printdbg("Software is up-to-date !") + launcherWindow.printmsg('Software is up-to-date !') + else: + logfile.printerr("An error occured. No effective update !") + launcherWindow.printmsg('An error occured. No effective update !') + time.sleep(2) + launcherWindow.exit() + return 0 except: logfile.printerr("A FATAL ERROR OCCURED : " + str(traceback.format_exc())) @@ -398,5 +433,6 @@ def umain(): sys.exit(2) return 2 - return - + time.sleep(2) + launcherWindow.exit() + return 0