mirror of
https://gitlab.os-k.eu/neox/CNIRevelator.git
synced 2023-08-25 14:03:10 +02:00
Correction of a bug in updater.py and preparing 3.1.1
This commit is contained in:
parent
73e06d37df
commit
dda773cd75
@ -42,7 +42,7 @@ try:
|
|||||||
from tkinter.messagebox import *
|
from tkinter.messagebox import *
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
except:
|
except:
|
||||||
critical.LASTCHANCECRASH()
|
critical.crashCNIR()
|
||||||
|
|
||||||
# Global handler
|
# Global handler
|
||||||
logfile = logger.logCur
|
logfile = logger.logCur
|
||||||
@ -87,7 +87,7 @@ try:
|
|||||||
# LANGUAGE
|
# LANGUAGE
|
||||||
lang.readLang()
|
lang.readLang()
|
||||||
except:
|
except:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
updater.exitProcess(1)
|
updater.exitProcess(1)
|
||||||
|
|
||||||
from main import * # main.py
|
from main import * # main.py
|
||||||
@ -96,7 +96,7 @@ try:
|
|||||||
launcherThread = threading.Thread(target=updater.umain, daemon=False)
|
launcherThread = threading.Thread(target=updater.umain, daemon=False)
|
||||||
launcher.lmain(launcherThread)
|
launcher.lmain(launcherThread)
|
||||||
except Exception:
|
except Exception:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
updater.exitProcess(1)
|
updater.exitProcess(1)
|
||||||
|
|
||||||
if updater.UPDATE_IS_MADE:
|
if updater.UPDATE_IS_MADE:
|
||||||
@ -116,10 +116,10 @@ try:
|
|||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
updater.exitProcess(1)
|
updater.exitProcess(1)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
critical.LASTCHANCECRASH()
|
critical.crashCNIR()
|
||||||
|
|
||||||
updater.exitProcess(0)
|
updater.exitProcess(0)
|
@ -23,6 +23,7 @@
|
|||||||
********************************************************************************
|
********************************************************************************
|
||||||
"""
|
"""
|
||||||
from tkinter.messagebox import *
|
from tkinter.messagebox import *
|
||||||
|
from importlib import reload
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import traceback
|
import traceback
|
||||||
@ -33,24 +34,33 @@ import lang # lang.py
|
|||||||
import logger # logger.py
|
import logger # logger.py
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
|
|
||||||
def LASTCHANCECRASH():
|
def crashCNIR(shutdown=True):
|
||||||
"""
|
"""
|
||||||
very last solution
|
very last solution
|
||||||
"""
|
"""
|
||||||
root = Tk()
|
|
||||||
root.withdraw()
|
try:
|
||||||
logfile = logger.logCur
|
root = Tk()
|
||||||
logfile.printerr("FATAL ERROR : see traceback below.\n{}".format(traceback.format_exc()))
|
root.withdraw()
|
||||||
showerror(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["CNIRevelator crashed because a fatal error occured. View log for more infos and please open an issue on Github"])
|
logfile = logger.logCur
|
||||||
res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open the log file ?"])
|
logfile.printerr("FATAL ERROR : see traceback below.\n{}".format(traceback.format_exc()))
|
||||||
if res == "yes":
|
showerror(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["CNIRevelator crashed because a fatal error occured. View log for more infos and please open an issue on Github"], parent=root)
|
||||||
webbrowser.open_new(globs.CNIRErrLog)
|
res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open the log file ?"], parent=root)
|
||||||
res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open an issue on Github to report this bug ?"])
|
if res == "yes":
|
||||||
if res == "yes":
|
webbrowser.open_new(globs.CNIRErrLog)
|
||||||
webbrowser.open_new("https://github.com/neox95/CNIRevelator/issues")
|
res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open an issue on Github to report this bug ?"], parent=root)
|
||||||
root.destroy()
|
if res == "yes":
|
||||||
# Quit totally without remain in memory
|
webbrowser.open_new("https://github.com/neox95/CNIRevelator/issues")
|
||||||
for process in psutil.process_iter():
|
root.destroy()
|
||||||
if process.pid == os.getpid():
|
|
||||||
process.terminate()
|
# Quit ?
|
||||||
sys.exit(arg)
|
if not shutdown:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Quit totally without remain in memory
|
||||||
|
for process in psutil.process_iter():
|
||||||
|
if process.pid == os.getpid():
|
||||||
|
process.terminate()
|
||||||
|
sys.exit(arg)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
@ -32,10 +32,11 @@ from Crypto.Cipher import AES
|
|||||||
from requests import Session
|
from requests import Session
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
|
import critical # critical.py
|
||||||
import logger # logger.py
|
import logger # logger.py
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
import ihm # ihm.py
|
import ihm # ihm.py
|
||||||
import lang # lang.py
|
import lang # lang.py
|
||||||
|
|
||||||
class AESCipher(object):
|
class AESCipher(object):
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import os
|
|||||||
|
|
||||||
# CNIRevelator version
|
# CNIRevelator version
|
||||||
verType = "final release"
|
verType = "final release"
|
||||||
version = [3, 1, 0]
|
version = [3, 1, 1]
|
||||||
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
|
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
|
||||||
verstring = "{}.{}".format(version[0], version[1])
|
verstring = "{}.{}".format(version[0], version[1])
|
||||||
|
|
||||||
|
41
src/ihm.py
41
src/ihm.py
@ -23,19 +23,21 @@
|
|||||||
********************************************************************************
|
********************************************************************************
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from tkinter import *
|
|
||||||
import webbrowser
|
|
||||||
from tkinter.messagebox import *
|
from tkinter.messagebox import *
|
||||||
|
from tkinter import *
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
import cv2
|
|
||||||
import PIL.Image, PIL.ImageTk
|
import PIL.Image, PIL.ImageTk
|
||||||
import traceback
|
import traceback
|
||||||
|
import webbrowser
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
import critical # critical.py
|
||||||
import logger # logger.py
|
import logger # logger.py
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
import lang # lang.py
|
import lang # lang.py
|
||||||
import updater # updater.py
|
import updater # updater.py
|
||||||
|
import critical # critical.py
|
||||||
|
|
||||||
controlKeys = ["Escape", "Right", "Left", "Up", "Down", "Home", "End", "BackSpace", "Delete", "Inser", "Shift_L", "Shift_R", "Control_R", "Control_L"]
|
controlKeys = ["Escape", "Right", "Left", "Up", "Down", "Home", "End", "BackSpace", "Delete", "Inser", "Shift_L", "Shift_R", "Control_R", "Control_L"]
|
||||||
|
|
||||||
@ -272,6 +274,12 @@ class LauncherWindow(Tk):
|
|||||||
Tk.__init__(self)
|
Tk.__init__(self)
|
||||||
self.resizable(width=False, height=False)
|
self.resizable(width=False, height=False)
|
||||||
|
|
||||||
|
# icon
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico')
|
||||||
|
else:
|
||||||
|
self.iconbitmap('id-card.ico')
|
||||||
|
|
||||||
# Setting up the geometry
|
# Setting up the geometry
|
||||||
ws = self.winfo_screenwidth()
|
ws = self.winfo_screenwidth()
|
||||||
hs = self.winfo_screenheight()
|
hs = self.winfo_screenheight()
|
||||||
@ -320,11 +328,6 @@ class LauncherWindow(Tk):
|
|||||||
self.update()
|
self.update()
|
||||||
self.progressBar.grid(row=1, sticky='S')
|
self.progressBar.grid(row=1, sticky='S')
|
||||||
|
|
||||||
|
|
||||||
if getattr(sys, 'frozen', False):
|
|
||||||
self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico')
|
|
||||||
else:
|
|
||||||
self.iconbitmap('id-card.ico')
|
|
||||||
logfile = logger.logCur
|
logfile = logger.logCur
|
||||||
logfile.printdbg('Launcher IHM successful')
|
logfile.printdbg('Launcher IHM successful')
|
||||||
self.protocol('WM_DELETE_WINDOW', lambda : 0)
|
self.protocol('WM_DELETE_WINDOW', lambda : 0)
|
||||||
@ -367,28 +370,6 @@ class StatusBar(Frame):
|
|||||||
self.label.config(text="")
|
self.label.config(text="")
|
||||||
self.label.update_idletasks()
|
self.label.update_idletasks()
|
||||||
|
|
||||||
## Crash
|
|
||||||
|
|
||||||
def crashCNIR():
|
|
||||||
"""
|
|
||||||
last solution
|
|
||||||
"""
|
|
||||||
# Global handler
|
|
||||||
logfile = logger.logCur
|
|
||||||
# hide main window
|
|
||||||
root = Tk()
|
|
||||||
root.withdraw()
|
|
||||||
logfile.printerr("FATAL ERROR : see traceback below.\n{}".format(traceback.format_exc()))
|
|
||||||
showerror(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["CNIRevelator crashed because a fatal error occured. View log for more infos and please open an issue on Github"])
|
|
||||||
res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open the log file ?"])
|
|
||||||
if res == "yes":
|
|
||||||
webbrowser.open_new(globs.CNIRErrLog)
|
|
||||||
res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open an issue on Github to report this bug ?"])
|
|
||||||
if res == "yes":
|
|
||||||
webbrowser.open_new("https://github.com/neox95/CNIRevelator/issues")
|
|
||||||
root.destroy()
|
|
||||||
|
|
||||||
|
|
||||||
## Global Handler
|
## Global Handler
|
||||||
launcherWindowCur = LauncherWindow()
|
launcherWindowCur = LauncherWindow()
|
||||||
|
|
||||||
|
15
src/lang.py
15
src/lang.py
@ -25,6 +25,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
|
import critical # critical.py
|
||||||
|
|
||||||
## FRENCH LANGUAGE
|
## FRENCH LANGUAGE
|
||||||
french = \
|
french = \
|
||||||
@ -137,7 +138,8 @@ french = \
|
|||||||
"Coller :\t\t\t\tCtrl-V \n"
|
"Coller :\t\t\t\tCtrl-V \n"
|
||||||
"Forcer une nouvelle détection du document :\tEchap\n",
|
"Forcer une nouvelle détection du document :\tEchap\n",
|
||||||
|
|
||||||
"CHANGELOG" : "Version 3.1.0 \nMise-à-jour majeure avec les progressions suivantes :\n- Modifications cosmétiques de l'interface utilisateur\n- Stabilisation des changements effectués sur la version mineure 3.0 : interface utilisateur, OCR, VISA A et B, logging\n- Rationalisation du système de langues\n- Ajout des canaux de mise-à-jour\n\n" + \
|
"CHANGELOG" : "Version 3.1.1 \nMise-à-jour mineure avec les progressions suivantes :\n- Correction d'un bug sévère du système de mise à jour\n\n" + \
|
||||||
|
"Version 3.1.0 \nMise-à-jour majeure avec les progressions suivantes :\n- Modifications cosmétiques de l'interface utilisateur\n- Stabilisation des changements effectués sur la version mineure 3.0 : interface utilisateur, OCR, VISA A et B, logging\n- Rationalisation du système de langues\n- Ajout des canaux de mise-à-jour\n\n" + \
|
||||||
"Version 3.0.8 finale\nCorrectif : bug du système de mise-à-jour'\n\n" + \
|
"Version 3.0.8 finale\nCorrectif : bug du système de mise-à-jour'\n\n" + \
|
||||||
"Version 3.0.6 \nMise-à-jour mineure avec les corrections suivantes :\n- Changement de l'apparence du launcher de l'application\n- Améliorations de l'interface, notamment de la stabilité\n- Ajout de la signature numérique de l'exécutable\n\n" + \
|
"Version 3.0.6 \nMise-à-jour mineure avec les corrections suivantes :\n- Changement de l'apparence du launcher de l'application\n- Améliorations de l'interface, notamment de la stabilité\n- Ajout de la signature numérique de l'exécutable\n\n" + \
|
||||||
"Version 3.0.7 finale\nMise-à-jour majeure avec les corrections suivantes :\n- Refonte de l'interface utilisateur\n- Fonction OCR intégrée à l'application avec support des TIFF et JPEG\n- Corrections d'erreurs sur le traitement des VISA de type A et B, ainsi que les titres de séjour\n\n" + \
|
"Version 3.0.7 finale\nMise-à-jour majeure avec les corrections suivantes :\n- Refonte de l'interface utilisateur\n- Fonction OCR intégrée à l'application avec support des TIFF et JPEG\n- Corrections d'erreurs sur le traitement des VISA de type A et B, ainsi que les titres de séjour\n\n" + \
|
||||||
@ -825,7 +827,8 @@ english = \
|
|||||||
"Paste:\t\t\t\tCtrl-V\n"
|
"Paste:\t\t\t\tCtrl-V\n"
|
||||||
"Force a new document detection:\tEchap\n",
|
"Force a new document detection:\tEchap\n",
|
||||||
|
|
||||||
"CHANGELOG" : "Version 3.1.0 \nMajor update with the following progressions: \n- Cosmetic modifications of the user interface \n- Stabilization of the changes made on the minor version 3.0 : user interface, OCR, VISA A and B, logging\n- Rationalization of the language system\n- Added update channels\n\n" + \
|
"CHANGELOG" : "Version 3.1.1 \nMinor update with the following progressions: \n- Fixed a severe bug in the update system" + \
|
||||||
|
"Version 3.1.0 \nMajor update with the following progressions: \n- Cosmetic modifications of the user interface \n- Stabilization of the changes made on the minor version 3.0 : user interface, OCR, VISA A and B, logging\n- Rationalization of the language system\n- Added update channels\n\n" + \
|
||||||
"Version 3.0.8 final\nCorrection: bug in the update system'\n\n" + \
|
"Version 3.0.8 final\nCorrection: bug in the update system'\n\n" + \
|
||||||
"Version 3.0.6 \nMinor update with the following fixes:\n- Change in the appearance of the application launcher\n- Improvements to the interface, including stability\n- Added digital signature of the executable\n" + \
|
"Version 3.0.6 \nMinor update with the following fixes:\n- Change in the appearance of the application launcher\n- Improvements to the interface, including stability\n- Added digital signature of the executable\n" + \
|
||||||
"Version 3.0.7 final\nMajor update with the following corrections: \n- Redesign of the user interface\n- OCR function integrated into the application with TIFF and JPEG support\n- Corrections of errors on the processing of VISA type A and B, as well as residence permits\n\n" + \
|
"Version 3.0.7 final\nMajor update with the following corrections: \n- Redesign of the user interface\n- OCR function integrated into the application with TIFF and JPEG support\n- Corrections of errors on the processing of VISA type A and B, as well as residence permits\n\n" + \
|
||||||
@ -1418,7 +1421,7 @@ def readLang():
|
|||||||
# Reading it
|
# Reading it
|
||||||
globs.CNIRlang = configFile.read()
|
globs.CNIRlang = configFile.read()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
raise IOError(str(e))
|
raise IOError(str(e))
|
||||||
else:
|
else:
|
||||||
# Recreating the url file
|
# Recreating the url file
|
||||||
@ -1432,7 +1435,7 @@ def readLang():
|
|||||||
# Writing it
|
# Writing it
|
||||||
configFile.write(globs.CNIRlang)
|
configFile.write(globs.CNIRlang)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
raise IOError(str(e))
|
raise IOError(str(e))
|
||||||
|
|
||||||
def updateLang(choice):
|
def updateLang(choice):
|
||||||
@ -1444,7 +1447,7 @@ def updateLang(choice):
|
|||||||
globs.CNIRlang = choice
|
globs.CNIRlang = choice
|
||||||
configFile.write(choice)
|
configFile.write(choice)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
raise IOError(str(e))
|
raise IOError(str(e))
|
||||||
else:
|
else:
|
||||||
# Recreating the url file
|
# Recreating the url file
|
||||||
@ -1458,5 +1461,5 @@ def updateLang(choice):
|
|||||||
# Writing it
|
# Writing it
|
||||||
configFile.write(globs.CNIRlang)
|
configFile.write(globs.CNIRlang)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
raise IOError(str(e))
|
raise IOError(str(e))
|
@ -27,6 +27,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
import critical # critical.py
|
||||||
import updater # updater.py
|
import updater # updater.py
|
||||||
import ihm # ihm.py
|
import ihm # ihm.py
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import critical # critical.py
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
|
|
||||||
## The logging class
|
## The logging class
|
||||||
|
17
src/main.py
17
src/main.py
@ -39,6 +39,7 @@ import os, shutil
|
|||||||
import webbrowser
|
import webbrowser
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
|
import critical # critical.py
|
||||||
import ihm # ihm.py
|
import ihm # ihm.py
|
||||||
import logger # logger.py
|
import logger # logger.py
|
||||||
import mrz # mrz.py
|
import mrz # mrz.py
|
||||||
@ -68,6 +69,12 @@ class mainWindow(Tk):
|
|||||||
self.corners = []
|
self.corners = []
|
||||||
self.validatedtext = ""
|
self.validatedtext = ""
|
||||||
|
|
||||||
|
# The icon
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico')
|
||||||
|
else:
|
||||||
|
self.iconbitmap('id-card.ico')
|
||||||
|
|
||||||
# Hide during construction
|
# Hide during construction
|
||||||
self.withdraw()
|
self.withdraw()
|
||||||
|
|
||||||
@ -349,12 +356,6 @@ class mainWindow(Tk):
|
|||||||
# The title
|
# The title
|
||||||
self.wm_title(globs.CNIRName)
|
self.wm_title(globs.CNIRName)
|
||||||
|
|
||||||
# The icon
|
|
||||||
if getattr(sys, 'frozen', False):
|
|
||||||
self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico')
|
|
||||||
else:
|
|
||||||
self.iconbitmap('id-card.ico')
|
|
||||||
|
|
||||||
# Make this window resizable and set her size
|
# Make this window resizable and set her size
|
||||||
self.resizable(0, 0)
|
self.resizable(0, 0)
|
||||||
self.update()
|
self.update()
|
||||||
@ -947,7 +948,7 @@ class mainWindow(Tk):
|
|||||||
self.DisplayUpdate( photo)
|
self.DisplayUpdate( photo)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logfile.printerr("Error with opencv : {}".format(e))
|
logfile.printerr("Error with opencv : {}".format(e))
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
try:
|
try:
|
||||||
# Reload an image using OpenCV
|
# Reload an image using OpenCV
|
||||||
path = self.imageViewer.imagePath
|
path = self.imageViewer.imagePath
|
||||||
@ -965,7 +966,7 @@ class mainWindow(Tk):
|
|||||||
self.DisplayUpdate(photo)
|
self.DisplayUpdate(photo)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logfile.printerr("Critical error with opencv : ".format(e))
|
logfile.printerr("Critical error with opencv : ".format(e))
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
showerror(lang.all[globs.CNIRlang]["OpenCV error (image processing)"], lang.all[globs.CNIRlang]["A critical error has occurred in the OpenCV image processing manager used by CNIRevelator, the application will reset itself"])
|
showerror(lang.all[globs.CNIRlang]["OpenCV error (image processing)"], lang.all[globs.CNIRlang]["A critical error has occurred in the OpenCV image processing manager used by CNIRevelator, the application will reset itself"])
|
||||||
self.initialize()
|
self.initialize()
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import datetime
|
|||||||
import logger # logger.py
|
import logger # logger.py
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
import lang # lang.py
|
import lang # lang.py
|
||||||
|
import critical # critical.py
|
||||||
|
|
||||||
## SEX CODES
|
## SEX CODES
|
||||||
sexcode = {'M':'Homme', 'F':'Femme', 'X':'Non spécifié'}
|
sexcode = {'M':'Homme', 'F':'Femme', 'X':'Non spécifié'}
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
|
from tkinter.messagebox import *
|
||||||
|
from tkinter import *
|
||||||
|
import pythoncom
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
@ -33,6 +36,7 @@ import hashlib
|
|||||||
import subprocess
|
import subprocess
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
|
import critical # critical.py
|
||||||
import ihm # ihm.py
|
import ihm # ihm.py
|
||||||
import logger # logger.py
|
import logger # logger.py
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
@ -93,6 +97,8 @@ def getLatestVersion(credentials):
|
|||||||
"""
|
"""
|
||||||
Returns the latest version of the software
|
Returns the latest version of the software
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
finalver, finalurl, finalchecksum = [None]*3
|
||||||
|
|
||||||
# Global Handlers
|
# Global Handlers
|
||||||
logfile = logger.logCur
|
logfile = logger.logCur
|
||||||
@ -155,7 +161,7 @@ def getLatestVersion(credentials):
|
|||||||
else:
|
else:
|
||||||
finalurl = url
|
finalurl = url
|
||||||
finalchecksum = None
|
finalchecksum = None
|
||||||
|
|
||||||
return (finalver, finalurl, finalchecksum)
|
return (finalver, finalurl, finalchecksum)
|
||||||
|
|
||||||
|
|
||||||
@ -167,6 +173,11 @@ def tessInstall(PATH, credentials):
|
|||||||
# Verifying that Tesseract is installed
|
# Verifying that Tesseract is installed
|
||||||
if not os.path.exists(PATH + '\\Tesseract-OCR4\\'):
|
if not os.path.exists(PATH + '\\Tesseract-OCR4\\'):
|
||||||
finalver, finalurl, finalchecksum = getLatestVersion(credentials)
|
finalver, finalurl, finalchecksum = getLatestVersion(credentials)
|
||||||
|
|
||||||
|
if finalurl == None:
|
||||||
|
logfile.printerr('Unable to get the Tesseract url')
|
||||||
|
return False
|
||||||
|
|
||||||
tesseracturl = finalurl.replace("CNIRevelator.zip", "tesseract_4.zip")
|
tesseracturl = finalurl.replace("CNIRevelator.zip", "tesseract_4.zip")
|
||||||
|
|
||||||
# WE ASSUME THAT THE MAIN FILE IS CNIRevelator.zip AND THAT THE TESSERACT PACKAGE IS tesseract_4.zip
|
# WE ASSUME THAT THE MAIN FILE IS CNIRevelator.zip AND THAT THE TESSERACT PACKAGE IS tesseract_4.zip
|
||||||
@ -277,6 +288,7 @@ def batch(credentials):
|
|||||||
|
|
||||||
# Make a shortcut
|
# Make a shortcut
|
||||||
# hide main window
|
# hide main window
|
||||||
|
pythoncom.CoInitialize()
|
||||||
root = Tk()
|
root = Tk()
|
||||||
root.withdraw()
|
root.withdraw()
|
||||||
res = askquestion(lang.all[globs.CNIRlang]["Shortcut creation"], lang.all[globs.CNIRlang]["Would you like to create/update the shortcut for CNIRevelator on your desktop ?"])
|
res = askquestion(lang.all[globs.CNIRlang]["Shortcut creation"], lang.all[globs.CNIRlang]["Would you like to create/update the shortcut for CNIRevelator on your desktop ?"])
|
||||||
@ -351,7 +363,7 @@ def umain():
|
|||||||
# EXECUTING THE UPDATE BATCH
|
# EXECUTING THE UPDATE BATCH
|
||||||
success = batch(credentials)
|
success = batch(credentials)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
launcherWindow.printmsg('ERROR : ' + str(e))
|
launcherWindow.printmsg('ERROR : ' + str(e))
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
launcherWindow.exit()
|
launcherWindow.exit()
|
||||||
@ -371,7 +383,7 @@ def umain():
|
|||||||
launcherWindow.exit()
|
launcherWindow.exit()
|
||||||
return 0
|
return 0
|
||||||
except:
|
except:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
launcherWindow.exit()
|
launcherWindow.exit()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
return 2
|
return 2
|
||||||
@ -381,7 +393,7 @@ def umain():
|
|||||||
# INSTALLING TESSERACT OCR
|
# INSTALLING TESSERACT OCR
|
||||||
success = tessInstall(globs.CNIRFolder, credentials)
|
success = tessInstall(globs.CNIRFolder, credentials)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
launcherWindow.printmsg('ERROR : ' + str(e))
|
launcherWindow.printmsg('ERROR : ' + str(e))
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
launcherWindow.exit()
|
launcherWindow.exit()
|
||||||
@ -398,7 +410,7 @@ def umain():
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
except:
|
except:
|
||||||
ihm.crashCNIR()
|
critical.crashCNIR()
|
||||||
launcherWindow.exit()
|
launcherWindow.exit()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
return 2
|
return 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user