From 072f1a251015338921a5b7b2325d489cc1c48efc Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 27 Aug 2019 13:24:12 +0200 Subject: [PATCH] Correction of a bug in bug reporting system --- src/critical.py | 3 ++- src/github.py | 10 +++++++++- src/globs.py | 5 +++-- src/main.py | 4 +++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/critical.py b/src/critical.py index d04f643..74cb1d2 100644 --- a/src/critical.py +++ b/src/critical.py @@ -57,12 +57,13 @@ def crashCNIR(shutdown=True): with open(globs.CNIRMainLog, 'r') as file: data = file.read() except: - pass + logfile.printerr("Can't read the log file.") # send it success = github.reportBug(traceback.format_exc(), data) if not success: + logfile.printerr("Can't send to 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) diff --git a/src/github.py b/src/github.py index 47c4730..1fd0e88 100644 --- a/src/github.py +++ b/src/github.py @@ -28,18 +28,26 @@ from pypac import PACSession from requests import Session import json +import logger # logger.py +import globs # globs.py + credentials = False def reportBug(reason="",log=""): + logfile = logger.logCur + if not credentials: + logfile.printerr("No credentials") return False session = credentials.sessionHandler payload = {'title':"CNIRevelator Bug Report", 'body':"**An error has been reported by a CNIRevelator instance.**\n\n**Here is the full reason of this issue:**\n{}\n\n**The full log is here:** {}".format(reason, log), "assignees":["neox95"], "labels":["bug", "AUTO"]} - handler = session.post('https://api.github.com/repos/neox95/cnirevelator/issues', headers={'Authorization': 'token %s' % "1a3c589eafc2b6557a1da852a3b2cc279bd5bf33"}, data=json.dumps(payload)) + handler = session.post('https://api.github.com/repos/neox95/cnirevelator/issues', headers={'Authorization': 'token %s' % globs.CNIRGitToken}, data=json.dumps(payload)) + + logfile.printdbg(handler.reason) if handler.reason == "Created": return True diff --git a/src/globs.py b/src/globs.py index bb8f289..8909ecd 100644 --- a/src/globs.py +++ b/src/globs.py @@ -26,12 +26,13 @@ import os # CNIRevelator version -verType = "final release" +verType = "stable release" version = [3, 1, 4] verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType) verstring = "{}.{}".format(version[0], version[1]) -CNIRTesserHash = '947224361ffab8c01f05c9394b44b1bd7c8c3d4d' +CNIRTesserHash = "947224361ffab8c01f05c9394b44b1bd7c8c3d4d" +CNIRGitToken = "23027ea52a48016d56f4ef759b8609981d564a46" CNIRFolder = os.path.dirname(os.path.realpath(__file__)) CNIRLColor = "#006699" CNIRName = "CNIRevelator {}".format(verstring) diff --git a/src/main.py b/src/main.py index 67d9031..6430527 100644 --- a/src/main.py +++ b/src/main.py @@ -385,7 +385,8 @@ class mainWindow(Tk): self.imageViewer.pagenumber = 0 # Some bindings - self.bind('', self.entryValidation) + self.bind('', self.entryValidation) + self.termtext.bind('', self.entryValidation) self.termtext.bind('<>', self.pasteValidation) self.speed731text.bind('', self.speedValidation) self.imageViewer.ZONE.bind("", self.rectangleSelectScan) @@ -632,6 +633,7 @@ class mainWindow(Tk): if not regex.fullmatch(event.char): self.logOnTerm(lang.all[globs.CNIRlang]["Character not accepted !\n"]) return "break" + # Adds the entry tempChar = self.termtext.get("1.0", "end")[:-1] self.mrzChar = tempChar[:pos+1] + event.char + tempChar[pos+1:] + '\n'