From 102b1d1e67967d5ad36dc484920aea75a7fd29eb Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 29 Aug 2019 11:04:50 +0200 Subject: [PATCH] Add files via upload --- src/updater.py | 57 +++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/src/updater.py b/src/updater.py index 5ca8d0e..8541aa4 100644 --- a/src/updater.py +++ b/src/updater.py @@ -371,25 +371,15 @@ def umain(): # Reading it lastUpdate = datetime.datetime.strptime(configFile.read(),"%d/%m/%Y") except Exception as e: - critical.crashCNIR() - raise IOError(str(e)) + critical.crashCNIR(False) + time.sleep(3) + launcherWindow.exit() + return 1 else: - # Recreating the url file - lastUpdate = currentDate - try: - os.mkdir(globs.CNIRFolder + '\\config') - except: - pass - - with open(globs.CNIRLastUpdate, 'w') as (configFile): - try: - # Writing it - configFile.write("{}/{}/{}".format(currentDate.day, currentDate.month, currentDate.year)) - except Exception as e: - critical.crashCNIR() - raise IOError(str(e)) + lastUpdate = datetime.datetime(1970,1,1) if not globs.CNIRNewVersion and os.path.exists(globs.CNIRFolder + '\\Tesseract-OCR5\\') and (currentDate - lastUpdate).days < 7: + logfile.printdbg("No need to update, {} days remaining".format(7 - (currentDate - lastUpdate).days)) launcherWindow.exit() return 0 @@ -399,7 +389,7 @@ def umain(): # EXECUTING THE UPDATE BATCH success = batch(credentials) except Exception as e: - critical.crashCNIR() + critical.crashCNIR(False) launcherWindow.printmsg('ERROR : ' + str(e)) time.sleep(3) launcherWindow.exit() @@ -408,20 +398,36 @@ def umain(): if success: logfile.printdbg("Software is up-to-date !") launcherWindow.printmsg('Software is up-to-date !') + # Recreating the url file + lastUpdate = currentDate + try: + os.mkdir(globs.CNIRFolder + '\\config') + except: + pass + + with open(globs.CNIRLastUpdate, 'w') as (configFile): + try: + # Writing it + configFile.write("{}/{}/{}".format(currentDate.day, currentDate.month, currentDate.year)) + except Exception as e: + critical.crashCNIR(False) + time.sleep(3) + launcherWindow.exit() + return + if UPDATE_IS_MADE: + launcherWindow.exit() + return 0 + else: logfile.printerr("An error occured. No effective update !") launcherWindow.printmsg(lang.all[globs.CNIRlang]['An error occured. No effective update !']) time.sleep(2) launcherWindow.exit() return 0 - - if UPDATE_IS_MADE: - launcherWindow.exit() - return 0 + except: - critical.crashCNIR() + critical.crashCNIR(False) launcherWindow.exit() - sys.exit(2) return 2 try: @@ -429,7 +435,7 @@ def umain(): # INSTALLING TESSERACT OCR success = tessInstall(globs.CNIRFolder, credentials) except Exception as e: - critical.crashCNIR() + critical.crashCNIR(False) launcherWindow.printmsg('ERROR : ' + str(e)) time.sleep(3) launcherWindow.exit() @@ -446,9 +452,8 @@ def umain(): return 0 except: - critical.crashCNIR() + critical.crashCNIR(False) launcherWindow.exit() - exitProcess(2) return 2 time.sleep(2)