diff --git a/src/globs.py b/src/globs.py index f35f0dd..919f921 100644 --- a/src/globs.py +++ b/src/globs.py @@ -25,12 +25,12 @@ import os # CNIRevelator version -version = [3, 0, 0] +version = [3, 0, 1] verstring_full = "{}.{}.{}".format(version[0], version[1], version[2]) verstring = "{}.{}".format(version[0], version[1]) debug = True -changelog = "Mise-à-jour majeure avec corrections suivantes :\n- Renouvellement de la signature numérique de l'exécutable\n- Amélioration de présentation du log en cas d'erreur\n- Refonte totale du code source et désobfuscation\n- Téléchargements en HTTPS fiables avec somme de contrôle" +changelog = "Mise-à-jour majeure avec les corrections suivantes :\n- Renouvellement de la signature numérique de l'exécutable\n- Amélioration de présentation du log en cas d'erreur\n- Refonte totale du code source et désobfuscation\n- Téléchargements en HTTPS fiables avec somme de contrôle\n- Nouveaux terminaux d'entrées : un rapide (731) et un complet\n- Détection des documents améliorée, possibilité de choix plus fin\n\naEt les regressions suivantes :\n- Suppression temporaire de la fonction de lecture OCR. Retour planifié pour une prochaine version" CNIRTesserHash = '5b58db27f7bc08c58a2cb33d01533b034b067cf8' CNIRFolder = os.getcwd() diff --git a/src/ihm.py b/src/ihm.py index 2693357..7bb5f9e 100644 --- a/src/ihm.py +++ b/src/ihm.py @@ -98,7 +98,7 @@ class LoginDialog(Toplevel): self.geometry('%dx%d+%d+%d' % (w, h, x, y)) self.bind("", self.connecti) - def connecti(self): + def connecti(self, event): self.login = self.entry_login.get().strip() self.key = self.entry_pass.get().strip() self.destroy() diff --git a/src/main.py b/src/main.py index 8d2b565..e3453b4 100644 --- a/src/main.py +++ b/src/main.py @@ -488,7 +488,7 @@ class mainWindow(Tk): #print(docInfos) # display the infos for key in [ e for e in docInfos ]: - print(docInfos[key]) + #print(docInfos[key]) if key in ["CODE", "CTRL"]: continue if not docInfos[key] == False: diff --git a/src/mrz.py b/src/mrz.py index bbb80bb..c9d55bf 100644 --- a/src/mrz.py +++ b/src/mrz.py @@ -838,7 +838,7 @@ def docMatch(doc, strs): # logfile.printdbg(" REGEX : {}, match : {}".format(regex, matching)) # exit the loop - logfile.printdbg("{} level : {}/{} (+{})".format(doc[2], level, nchar, bonus)) + #logfile.printdbg("{} level : {}/{} (+{})".format(doc[2], level, nchar, bonus)) return (level, nchar, bonus) def allDocMatch(strs, final=False): @@ -963,7 +963,7 @@ def getDocInfos(doc, code): for field in infoTypes: - value = code[ field[1][0] : field[1][1] ] + value = code[ field[1][0] : field[1][1] ].replace("<", " ").strip() # State code if field[0] == 'PAYS' or field[0] == 'NAT': @@ -1008,11 +1008,14 @@ def getDocInfos(doc, code): res["NO"] = value elif field[0] == 'FACULT': - res["INDIC"] += value + try: + res["INDIC"] += value + except KeyError: + res["INDIC"] = value # All other cases else: if value != "": - res[field[0]] = value.replace("<", " ").strip() + res[field[0]] = value return res diff --git a/src/updater.py b/src/updater.py index 6578b92..db7113a 100644 --- a/src/updater.py +++ b/src/updater.py @@ -270,7 +270,33 @@ def umain(): return 0 # Cleaner for the old version if detected - if len(sys.argv) > 1: + if len(sys.argv) > 2: + globs.CNIRNewVersion = True + launcherWindow.printmsg('Deleting old version !') + logfile.printdbg("Old install detected : {}".format(sys.argv[1])) + while os.path.exists(str(sys.argv[2])): + try: + os.remove(str(sys.argv[2])) + except Exception as e: + logfile.printerr(str(e)) + logfile.printdbg('Trying stop the process !') + launcherWindow.printmsg('Fail :{}'.format(e)) + try: + for process in psutil.process_iter(): + if process.name() == 'CNIRevelator.exe': + logfile.printdbg('Process found. Command line: {}'.format(process.cmdline())) + if process.pid == os.getpid(): + logfile.printdbg("Don't touch us ! {} = {}".format(process.pid, os.getpid())) + else: + logfile.printdbg('Terminating process !') + process.terminate() + os.remove(str(sys.argv[2])) + break + except Exception as e: + logfile.printerr(str(e)) + launcherWindow.printmsg('Fail :{}'.format(e)) + launcherWindow.printmsg('Starting...') + elif len(sys.argv) > 1: globs.CNIRNewVersion = True launcherWindow.printmsg('Deleting old version !') logfile.printdbg("Old install detected : {}".format(sys.argv[1])) @@ -290,6 +316,7 @@ def umain(): else: logfile.printdbg('Terminating process !') process.terminate() + shutil.rmtree(str(sys.argv[1])) break except Exception as e: logfile.printerr(str(e))