From b9a24fca1e428b0e8d9b2c5a870588a7cd7ac104 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 12 Aug 2019 18:11:56 +0200 Subject: [PATCH] Bug with open file --- src/CNIRevelator.py | 27 +++++++++++++++++---------- src/critical.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/globs.py | 2 +- src/updater.py | 1 + 4 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 src/critical.py diff --git a/src/CNIRevelator.py b/src/CNIRevelator.py index 8ab8c85..3d49ce2 100644 --- a/src/CNIRevelator.py +++ b/src/CNIRevelator.py @@ -23,22 +23,30 @@ * along with CNIRevelator. If not, see . * ******************************************************************************** """ - +# Import critical files import sys import os import subprocess import threading import psutil -from tkinter import * -from tkinter.messagebox import * +import traceback -import launcher # launcher.py" -import updater # updater.py -import globs # globs.py -import pytesseract # pytesseract.py -import logger # logger.py import lang # lang.py -import ihm # ihm.py +import logger # logger.py +import globs # globs.py +import critical # critical.py + +# Import all other files +try: + + import launcher # launcher.py" + import updater # updater.py + import pytesseract # pytesseract.py + import ihm # ihm.py + from tkinter.messagebox import * + from tkinter import * +except: + critical.LASTCHANCECRASH() from main import * # main.py @@ -78,7 +86,6 @@ def main(): ## BOOTSTRAP OF CNIREVELATOR - try: # LANGUAGE if os.path.isfile(globs.CNIRLangFile): diff --git a/src/critical.py b/src/critical.py new file mode 100644 index 0000000..9ff07b9 --- /dev/null +++ b/src/critical.py @@ -0,0 +1,45 @@ +""" +******************************************************************************** +* CNIRevelator * +* * +* Desc: Critical Stuff for CNIRevelator * +* * +* Copyright © 2018-2019 Adrien Bourmault (neox95) * +* * +* This file is part of CNIRevelator. * +* * +* CNIRevelator is free software: you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation, either version 3 of the License, or * +* any later version. * +* * +* CNIRevelator is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY*without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with CNIRevelator. If not, see . * +******************************************************************************** +""" +from tkinter.messagebox import * +from tkinter import * + +import lang # lang.py +import logger # logger.py + +def LASTCHANCECRASH(): + 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 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) \ No newline at end of file diff --git a/src/globs.py b/src/globs.py index c2a554a..2f4b850 100644 --- a/src/globs.py +++ b/src/globs.py @@ -34,7 +34,7 @@ debug = True 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" CNIRTesserHash = '5b58db27f7bc08c58a2cb33d01533b034b067cf8' -CNIRFolder = os.getcwd() +CNIRFolder = os.path.dirname(os.path.realpath(__file__)) CNIRLColor = "#006699" CNIRName = "CNIRevelator {}".format(verstring) CNIRCryptoKey = '82Xh!efX3#@P~2eG' diff --git a/src/updater.py b/src/updater.py index 0840c78..8f8e15f 100644 --- a/src/updater.py +++ b/src/updater.py @@ -336,6 +336,7 @@ def umain(): # check we want open a file elif len(sys.argv) > 1 and str(sys.argv[1]) != "DELETE": globs.CNIROpenFile = True + print(sys.argv) try: try: