1
0
mirror of https://gitlab.os-k.eu/neox/CNIRevelator.git synced 2023-08-25 14:03:10 +02:00

Merge pull request #3 from neox95/v3.0

V3.0.2 release
This commit is contained in:
Adrien Bourmault 2019-08-05 16:44:42 +02:00 committed by GitHub
commit cd6f590d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 84 additions and 45 deletions

View File

@ -1,2 +1,2 @@
# ver|url|checksum, and | as separator, one version per ||
3.0.1|https://github.com/neox95/CNIRevelator/releases/download/3.0.1/CNIRevelator.zip|bd585c98435395471d14c89405f68ace4ec89256||
3.0.1|https://github.com/neox95/CNIRevelator/releases/download/3.0.1/CNIRevelator.zip|bd585c98435395471d14c89405f68ace4ec89256||3.0.2|https://github.com/neox95/CNIRevelator/releases/download/3.0.2/CNIRevelator.zip|f472ee2edbff1ae62a30211614d15674bcc31ca7||

View File

@ -157,15 +157,16 @@ class newcredentials:
return
class newdownload:
def __init__(self, credentials, urlFile, destinationFile):
def __init__(self, credentials, urlFile, destinationFile, title):
self.urlFile = urlFile
self.destinationFile = destinationFile
self.session = credentials.sessionHandler
self.title = title
logfile = logger.logCur
launcherWindow = ihm.launcherWindowCur
logfile.printdbg('Requesting download of {}'.format(self.urlFile))
logfile.printdbg('Requesting download of {}'.format(urlFile))
self.handler = self.session.get(self.urlFile, stream=True, headers={'Connection' : 'close', "Cache-Control": "no-cache", "Pragma": "no-cache"})
self.handler.raise_for_status()
@ -179,10 +180,12 @@ class newdownload:
launcherWindow = ihm.launcherWindowCur
url = self.urlFile
filename = self.destinationFile
title = self.title
reducedFilename = filename.split("\\")[-1]
launcherWindow.printmsg('Downloading {}'.format(reducedFilename))
launcherWindow.printmsg('Downloading {}'.format(title))
logfile.printdbg('Requesting download of {}'.format(reducedFilename))
try:
os.remove(filename)
@ -198,7 +201,7 @@ class newdownload:
launcherWindow.progressBar.stop()
launcherWindow.progressBar.configure(mode='determinate', value=(int(Percent)), maximum=100)
launcherWindow.printmsg('Downloading {}'.format(reducedFilename) + ' : {:4.2f} %'.format(Percent))
launcherWindow.printmsg('Downloading {}'.format(title) + ' : {:4.2f} %'.format(Percent))
launcherWindow.progressBar.configure(mode='indeterminate', value=0, maximum=20)
launcherWindow.progressBar.start()

View File

@ -25,19 +25,21 @@
import os
# CNIRevelator version
version = [3, 0, 1]
verstring_full = "{}.{}.{}".format(version[0], version[1], version[2])
verType = "alpha"
version = [3, 0, 2]
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
verstring = "{}.{}".format(version[0], version[1])
debug = True
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"
changelog = "Version 3.0.2 \nMise-à-jour mineure avec les corrections suivantes :\n- Changement d'icône de l'exécutable\n- Correction d'un bug affectant le logging\n- Correction d'un bug affectant la détection de documents\n- Et autres modifications mineures\n\n" + \
"Version 3.0.1 \nMise-à-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\nEt les regressions suivantes :\n- Suppression temporaire de la fonction de lecture OCR. Retour planifié pour une prochaine version"
CNIRTesserHash = '5b58db27f7bc08c58a2cb33d01533b034b067cf8'
CNIRFolder = os.getcwd()
CNIRLColor = "#006699"
CNIRName = "CNIRevelator {}".format(verstring)
CNIRCryptoKey = '82Xh!efX3#@P~2eG'
CNIRNewVersion = False
CNIRNewVersion = True
CNIRConfig = CNIRFolder + '\\config\\conf.ig'
CNIRErrLog = CNIRFolder + '\\logs\\error.log'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -32,7 +32,7 @@ import logger # logger.py
import globs # globs.py
controlKeys = ["Right", "Left", "Up", "Down", "Home", "End", "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"]
class DocumentAsk(Toplevel):
@ -98,7 +98,7 @@ class LoginDialog(Toplevel):
self.geometry('%dx%d+%d+%d' % (w, h, x, y))
self.bind("<Return>", self.connecti)
def connecti(self, event):
def connecti(self, event=None):
self.login = self.entry_login.get().strip()
self.key = self.entry_pass.get().strip()
self.destroy()

View File

@ -60,9 +60,13 @@ class NewLoggingSystem:
self.logger = logger
self.printerr = logger.error
def printdbg(self, text):
if globs.debug:
self.logger.info(text)
self.printdbg = self.logger.info
else:
self.printdbg = self.doNothing
def doNothing(self, text):
pass
def close(self):
logging.shutdown()

View File

@ -267,6 +267,8 @@ class mainWindow(Tk):
self.logOnTerm("Document detecté : {}\n".format(candidates[0][2]))
self.mrzDecided = candidates[0]
else:
# get the cursor position
curPos = self.termtext.index(INSERT)
# break the line
if (len(self.mrzChar) - 2 >= len(self.mrzDecided[0][0])) and ("\n" not in self.mrzChar[:-1]):
# In case of there is no second line
@ -274,6 +276,7 @@ class mainWindow(Tk):
self.mrzChar = self.termtext.get("1.0", "end")[:-1]
self.termtext.delete("1.0","end")
self.termtext.insert("1.0", self.mrzChar[:-1])
self.termtext.mark_set(INSERT, curPos)
else:
# In case of there is a second line
self.mrzChar = self.termtext.get("1.0", "end")[:-1] + '\n'
@ -284,6 +287,7 @@ class mainWindow(Tk):
self.mrzChar = self.termtext.get("1.0", "end")[:-1]
self.termtext.delete("1.0","end")
self.termtext.insert("1.0", self.mrzChar[:-1])
self.termtext.mark_set(INSERT, curPos)
# compute the control sum if needed
self.computeSigma()
@ -328,6 +332,27 @@ class mainWindow(Tk):
self.termtext.mark_set("insert", "%d.%d" % (int(position[0]), int(position[1]) + number))
return "break"
if event.keysym == "Escape":
if self.mrzDecided:
# Get the candidates
candidates = mrz.allDocMatch(self.mrzChar.split("\n"))
if len(candidates) == 2 and len(self.mrzChar) >= 8:
# Parameters for the choice invite
invite = ihm.DocumentAsk(self, [candidates[0][2], candidates[1][2]])
invite.transient(self)
invite.grab_set()
invite.focus_force()
self.wait_window(invite)
self.logOnTerm("Document re-detecté : {}\n".format(candidates[invite.choice][2]))
self.mrzDecided = candidates[invite.choice]
elif len(candidates) == 1:
self.logOnTerm("Document re-detecté : {}\n".format(candidates[0][2]))
self.mrzDecided = candidates[0]
return "break"
# If not a control char
if not controlled and not event.keysym in ihm.controlKeys:
@ -434,8 +459,19 @@ class mainWindow(Tk):
Tk().withdraw()
showinfo('Aide sur les contrôles au clavier',
( '' + '\n\n' +
"In construction"
( "Terminal de saisie rapide (731) : \n\n"
" Caractères autorisés : Alphanumériques en majuscule et le caractère '<'. Pas de minuscules ni caractères spéciaux, autrement la somme est mise à zéro \n\n"
" Calculer résultat :\t\t\tTouche Ctrl droite \n"
" Copier :\t\t\t\tCtrl-C \n"
" Coller :\t\t\t\tCtrl-V \n"
"\n\n"
"Terminal de saisie MRZ complète : \n\n"
" Caractères autorisés : Alphanumériques en majuscule et le caractère '<'. Pas de minuscules ni caractères spéciaux, autrement la somme est mise à zéro \n\n"
" Calculer résultat :\t\t\tTouche Ctrl droite \n"
" Compléter champ :\t\t\tTouche Tab \n"
" Copier :\t\t\t\tCtrl-C \n"
" Coller :\t\t\t\tCtrl-V \n"
" Forcer une nouvelle détection du document :\tEchap\n"
),
parent=self)
@ -467,15 +503,19 @@ class mainWindow(Tk):
self.logOnTerm("Somme de contrôle position {} : Lu {} VS Calculé {}\n".format(sum[1], code[sum[1]], sum[2]))
# if sum is facultative or if sum is ok
if sum[3] or int(code[sum[1]]) == int(sum[2]):
self.termtext.tag_add("conforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1))
self.termtext.tag_configure("conforme", background="green", foreground="white")
else:
try:
if sum[3] or int(code[sum[1]]) == int(sum[2]):
self.termtext.tag_add("conforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1))
self.termtext.tag_configure("conforme", background="green", foreground="white")
else:
self.termtext.tag_add("nonconforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1))
self.termtext.tag_configure("nonconforme", background="red", relief='raised', foreground="white")
self.compliance = False
except ValueError:
self.termtext.tag_add("nonconforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1))
self.termtext.tag_configure("nonconforme", background="red", relief='raised', foreground="white")
self.compliance = False
if self.compliance == True:
self.STATUStxt['text'] = 'CONFORME'
self.STATUStxt['fg'] = "green"

View File

@ -1,15 +0,0 @@
import globs
import psutil
import os
for process in psutil.process_iter():
if process.name() == 'CNIRevelator.exe':
print('Process found. Command line: {}'.format(process.cmdline()))
if True:
print(process.pid)
continue
else:
print('Terminating process !')
#process.terminate()
break

View File

@ -120,8 +120,8 @@ def getLatestVersion(credentials):
os.mkdir(globs.CNIRFolder + '\\downloads')
except:
pass
getTheVersions = downloader.newdownload(credentials, urlparsed[0], globs.CNIRVerStock).download()
getTheVersions = downloader.newdownload(credentials, urlparsed[0], globs.CNIRVerStock, "the version repository").download()
logfile.printdbg('Parsing the software versions')
with open(globs.CNIRVerStock) as versionsFile:
versionsTab = versionsFile.read().split("\n")[1].split("||")
@ -130,7 +130,7 @@ def getLatestVersion(credentials):
finalver = globs.version.copy()
for entry in versionsTab:
if not entry:
break
continue
verstr, url, checksum = entry.split("|")
# Calculating sum considering we can have 99 sub versions
ver = verstr.split(".")
@ -142,9 +142,14 @@ def getLatestVersion(credentials):
finalver = ver.copy()
finalurl = url
finalchecksum = checksum
else:
finalurl = None
finalchecksum = None
return (finalver, finalurl, finalchecksum)
# XXX Warning : when tesseracturl is not found, it seems to hang and freeze
def tessInstall(PATH, credentials):
# Global Handlers
logfile = logger.logCur
@ -157,18 +162,18 @@ def tessInstall(PATH, credentials):
# WE ASSUME THAT THE MAIN FILE IS CNIRevelator.zip AND THAT THE TESSERACT PACKAGE IS tesseract_4.zip
logfile.printdbg('Preparing download of Tesseract OCR 4...')
getTesseract = downloader.newdownload(credentials, tesseracturl, PATH + '\\TsrtPackage.zip').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 + '\\TsrtPackage.zip', 'r')
zip_ref = zipfile.ZipFile(PATH + '\\downloads\\TsrtPackage.zip', 'r')
zip_ref.extractall(PATH)
zip_ref.close()
# Cleanup
try:
os.remove(UPATH + '\\TsrtPackage.zip')
os.remove(UPATH + '\\downloads\\TsrtPackage.zip')
except:
pass
@ -187,7 +192,7 @@ def batch(credentials):
logfile.printdbg('Preparing download for the new version')
getTheUpdate = downloader.newdownload(credentials, finalurl, globs.CNIRFolder + '\\..\\CNIPackage.zip').download()
getTheUpdate = downloader.newdownload(credentials, finalurl, globs.CNIRFolder + '\\downloads\\CNIPackage.zip', "CNIRevelator {}.{}.{}".format(finalver[0], finalver[1], finalver[2])).download()
launcherWindow.printmsg('Verifying download...')
@ -196,7 +201,7 @@ def batch(credentials):
sha1 = hashlib.sha1()
with open(globs.CNIRFolder + '\\..\\CNIPackage.zip', 'rb') as f:
with open(globs.CNIRFolder + '\\downloads\\CNIPackage.zip', 'rb') as f:
while True:
data = f.read(BUF_SIZE)
if not data:
@ -227,7 +232,7 @@ def batch(credentials):
# Unzip
logfile.printdbg("Unzipping the package")
launcherWindow.printmsg('Installing the updates')
zip_ref = zipfile.ZipFile(globs.CNIRFolder + '\\..\\CNIPackage.zip', 'r')
zip_ref = zipfile.ZipFile(globs.CNIRFolder + '\\downloads\\CNIPackage.zip', 'r')
zip_ref.extractall(UPATH + "temp")
zip_ref.close()
@ -243,7 +248,7 @@ def batch(credentials):
# Cleanup
try:
os.remove(globs.CNIRFolder + '\\..\\CNIPackage.zip')
os.remove(globs.CNIRFolder + '\\downloads\\CNIPackage.zip')
except:
pass
# Time to quit