2019-08-21 14:54:05 +02:00
# -*- coding: utf8 -*-
2019-08-12 18:11:56 +02:00
"""
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 < https : * www . gnu . org / licenses / > . *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
"""
from tkinter . messagebox import *
2019-08-20 10:14:54 +02:00
from importlib import reload
2019-08-12 18:11:56 +02:00
from tkinter import *
2019-08-19 17:56:23 +02:00
import webbrowser
import traceback
import psutil
import os
2019-08-12 18:11:56 +02:00
2019-08-23 16:46:25 +02:00
import lang # lang.py
import logger # logger.py
import globs # globs.py
import github # github.py
2019-08-12 18:11:56 +02:00
2019-08-20 10:14:54 +02:00
def crashCNIR ( shutdown = True ) :
2019-08-19 17:56:23 +02:00
"""
very last solution
"""
2019-08-20 10:14:54 +02:00
try :
root = Tk ( )
root . withdraw ( )
logfile = logger . logCur
logfile . printerr ( " FATAL ERROR : see traceback below. \n {} " . format ( traceback . format_exc ( ) ) )
2019-08-23 16:46:25 +02:00
2019-08-20 18:38:22 +02:00
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 " ] )
2019-08-23 16:46:25 +02:00
res = askquestion ( lang . all [ globs . CNIRlang ] [ " CNIRevelator Fatal Eror " ] , lang . all [ globs . CNIRlang ] [ " Would you like to report this bug ? " ] )
2019-08-20 10:14:54 +02:00
if res == " yes " :
2019-08-23 16:46:25 +02:00
# read the log
data = " No log. "
try :
with open ( globs . CNIRMainLog , ' r ' ) as file :
data = file . read ( )
except :
pass
# send it
success = github . reportBug ( traceback . format_exc ( ) , data )
if not success :
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 )
else :
showinfo ( lang . all [ globs . CNIRlang ] [ " CNIRevelator Fatal Eror " ] , lang . all [ globs . CNIRlang ] [ " Bug reported successfully. Thanks. " ] )
2019-08-20 10:14:54 +02:00
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 ( )