Correction of a bug in updater.py and preparing 3.1.1

This commit is contained in:
Adrien Bourmault 2019-08-20 10:14:54 +02:00 committed by GitHub
parent 73e06d37df
commit dda773cd75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 85 additions and 74 deletions

View File

@ -42,7 +42,7 @@ try:
from tkinter.messagebox import *
from tkinter import *
except:
critical.LASTCHANCECRASH()
critical.crashCNIR()
# Global handler
logfile = logger.logCur
@ -87,7 +87,7 @@ try:
# LANGUAGE
lang.readLang()
except:
ihm.crashCNIR()
critical.crashCNIR()
updater.exitProcess(1)
from main import * # main.py
@ -96,7 +96,7 @@ try:
launcherThread = threading.Thread(target=updater.umain, daemon=False)
launcher.lmain(launcherThread)
except Exception:
ihm.crashCNIR()
critical.crashCNIR()
updater.exitProcess(1)
if updater.UPDATE_IS_MADE:
@ -116,10 +116,10 @@ try:
try:
main()
except Exception as e:
ihm.crashCNIR()
critical.crashCNIR()
updater.exitProcess(1)
except:
critical.LASTCHANCECRASH()
critical.crashCNIR()
updater.exitProcess(0)

View File

@ -23,6 +23,7 @@
********************************************************************************
"""
from tkinter.messagebox import *
from importlib import reload
from tkinter import *
import webbrowser
import traceback
@ -33,24 +34,33 @@ import lang # lang.py
import logger # logger.py
import globs # globs.py
def LASTCHANCECRASH():
def crashCNIR(shutdown=True):
"""
very last solution
"""
root = Tk()
root.withdraw()
logfile = logger.logCur
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()
# Quit totally without remain in memory
for process in psutil.process_iter():
if process.pid == os.getpid():
process.terminate()
sys.exit(arg)
try:
root = Tk()
root.withdraw()
logfile = logger.logCur
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"], parent=root)
res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open the log file ?"], parent=root)
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 ?"], parent=root)
if res == "yes":
webbrowser.open_new("https://github.com/neox95/CNIRevelator/issues")
root.destroy()
# Quit ?
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()

View File

@ -32,10 +32,11 @@ from Crypto.Cipher import AES
from requests import Session
from time import time
import critical # critical.py
import logger # logger.py
import globs # globs.py
import ihm # ihm.py
import lang # lang.py
import lang # lang.py
class AESCipher(object):

View File

@ -26,7 +26,7 @@ import os
# CNIRevelator version
verType = "final release"
version = [3, 1, 0]
version = [3, 1, 1]
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
verstring = "{}.{}".format(version[0], version[1])

View File

@ -23,19 +23,21 @@
********************************************************************************
"""
from tkinter import *
import webbrowser
from tkinter.messagebox import *
from tkinter import *
from tkinter import filedialog
from tkinter import ttk
import cv2
import PIL.Image, PIL.ImageTk
import traceback
import webbrowser
import cv2
import critical # critical.py
import logger # logger.py
import globs # globs.py
import lang # lang.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"]
@ -272,6 +274,12 @@ class LauncherWindow(Tk):
Tk.__init__(self)
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
ws = self.winfo_screenwidth()
hs = self.winfo_screenheight()
@ -320,11 +328,6 @@ class LauncherWindow(Tk):
self.update()
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.printdbg('Launcher IHM successful')
self.protocol('WM_DELETE_WINDOW', lambda : 0)
@ -367,28 +370,6 @@ class StatusBar(Frame):
self.label.config(text="")
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
launcherWindowCur = LauncherWindow()

View File

@ -25,6 +25,7 @@
import os
import globs # globs.py
import critical # critical.py
## FRENCH LANGUAGE
french = \
@ -137,7 +138,8 @@ french = \
"Coller :\t\t\t\tCtrl-V \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.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" + \
@ -825,7 +827,8 @@ english = \
"Paste:\t\t\t\tCtrl-V\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.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" + \
@ -1418,7 +1421,7 @@ def readLang():
# Reading it
globs.CNIRlang = configFile.read()
except Exception as e:
ihm.crashCNIR()
critical.crashCNIR()
raise IOError(str(e))
else:
# Recreating the url file
@ -1432,7 +1435,7 @@ def readLang():
# Writing it
configFile.write(globs.CNIRlang)
except Exception as e:
ihm.crashCNIR()
critical.crashCNIR()
raise IOError(str(e))
def updateLang(choice):
@ -1444,7 +1447,7 @@ def updateLang(choice):
globs.CNIRlang = choice
configFile.write(choice)
except Exception as e:
ihm.crashCNIR()
critical.crashCNIR()
raise IOError(str(e))
else:
# Recreating the url file
@ -1458,5 +1461,5 @@ def updateLang(choice):
# Writing it
configFile.write(globs.CNIRlang)
except Exception as e:
ihm.crashCNIR()
critical.crashCNIR()
raise IOError(str(e))

View File

@ -27,6 +27,7 @@ import sys
import os
import threading
import critical # critical.py
import updater # updater.py
import ihm # ihm.py
import globs # globs.py

View File

@ -26,6 +26,7 @@
import logging
import os
import critical # critical.py
import globs # globs.py
## The logging class

View File

@ -39,6 +39,7 @@ import os, shutil
import webbrowser
import sys, os
import critical # critical.py
import ihm # ihm.py
import logger # logger.py
import mrz # mrz.py
@ -68,6 +69,12 @@ class mainWindow(Tk):
self.corners = []
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
self.withdraw()
@ -349,12 +356,6 @@ class mainWindow(Tk):
# The title
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
self.resizable(0, 0)
self.update()
@ -947,7 +948,7 @@ class mainWindow(Tk):
self.DisplayUpdate( photo)
except Exception as e:
logfile.printerr("Error with opencv : {}".format(e))
ihm.crashCNIR()
critical.crashCNIR()
try:
# Reload an image using OpenCV
path = self.imageViewer.imagePath
@ -965,7 +966,7 @@ class mainWindow(Tk):
self.DisplayUpdate(photo)
except Exception as 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"])
self.initialize()

View File

@ -30,6 +30,7 @@ import datetime
import logger # logger.py
import globs # globs.py
import lang # lang.py
import critical # critical.py
## SEX CODES
sexcode = {'M':'Homme', 'F':'Femme', 'X':'Non spécifié'}

View File

@ -24,6 +24,9 @@
"""
from win32com.client import Dispatch
from tkinter.messagebox import *
from tkinter import *
import pythoncom
import sys
import time
import os
@ -33,6 +36,7 @@ import hashlib
import subprocess
import psutil
import critical # critical.py
import ihm # ihm.py
import logger # logger.py
import globs # globs.py
@ -93,6 +97,8 @@ def getLatestVersion(credentials):
"""
Returns the latest version of the software
"""
finalver, finalurl, finalchecksum = [None]*3
# Global Handlers
logfile = logger.logCur
@ -155,7 +161,7 @@ def getLatestVersion(credentials):
else:
finalurl = url
finalchecksum = None
return (finalver, finalurl, finalchecksum)
@ -167,6 +173,11 @@ def tessInstall(PATH, credentials):
# Verifying that Tesseract is installed
if not os.path.exists(PATH + '\\Tesseract-OCR4\\'):
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")
# 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
# hide main window
pythoncom.CoInitialize()
root = Tk()
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 ?"])
@ -351,7 +363,7 @@ def umain():
# EXECUTING THE UPDATE BATCH
success = batch(credentials)
except Exception as e:
ihm.crashCNIR()
critical.crashCNIR()
launcherWindow.printmsg('ERROR : ' + str(e))
time.sleep(3)
launcherWindow.exit()
@ -371,7 +383,7 @@ def umain():
launcherWindow.exit()
return 0
except:
ihm.crashCNIR()
critical.crashCNIR()
launcherWindow.exit()
sys.exit(2)
return 2
@ -381,7 +393,7 @@ def umain():
# INSTALLING TESSERACT OCR
success = tessInstall(globs.CNIRFolder, credentials)
except Exception as e:
ihm.crashCNIR()
critical.crashCNIR()
launcherWindow.printmsg('ERROR : ' + str(e))
time.sleep(3)
launcherWindow.exit()
@ -398,7 +410,7 @@ def umain():
return 0
except:
ihm.crashCNIR()
critical.crashCNIR()
launcherWindow.exit()
sys.exit(2)
return 2