Update system hotfix

This commit is contained in:
Adrien Bourmault 2019-08-11 21:16:20 +02:00
parent 767519b2a7
commit 99aa337a4c
1 changed files with 51 additions and 15 deletions

View File

@ -207,18 +207,24 @@ def tessInstall(PATH, credentials):
logfile.printdbg('Preparing download of Tesseract OCR 4...') logfile.printdbg('Preparing download of Tesseract OCR 4...')
getTesseract = downloader.newdownload(credentials, tesseracturl, PATH + '\\downloads\\TsrtPackage.zip', "Tesseract 4 OCR Module").download() 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: 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: except:
pass return False
else:
return True
## Main Batch Function ## Main Batch Function
def batch(credentials): def batch(credentials):
@ -374,7 +380,6 @@ def umain():
try: try:
# EXECUTING THE UPDATE BATCH # EXECUTING THE UPDATE BATCH
success = batch(credentials) success = batch(credentials)
tessInstall(globs.CNIRFolder, credentials)
except Exception as e: except Exception as e:
logfile.printerr("An error occured on the thread : " + str(traceback.format_exc())) logfile.printerr("An error occured on the thread : " + str(traceback.format_exc()))
launcherWindow.printmsg('ERROR : ' + str(e)) launcherWindow.printmsg('ERROR : ' + str(e))
@ -388,9 +393,39 @@ def umain():
else: else:
logfile.printerr("An error occured. No effective update !") logfile.printerr("An error occured. No effective update !")
launcherWindow.printmsg('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() 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: except:
logfile.printerr("A FATAL ERROR OCCURED : " + str(traceback.format_exc())) logfile.printerr("A FATAL ERROR OCCURED : " + str(traceback.format_exc()))
@ -398,5 +433,6 @@ def umain():
sys.exit(2) sys.exit(2)
return 2 return 2
return time.sleep(2)
launcherWindow.exit()
return 0