--- a/Beremiz.py Fri Jan 27 13:04:25 2017 +0300
+++ b/Beremiz.py Fri Jan 27 16:01:23 2017 +0300
@@ -1223,50 +1223,48 @@
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]):
+ def save_bug_report(e_type, e_value, e_traceback, bug_report_path,date): + 'app-title': wx.GetApp().GetAppName(), # app_title + 'app-version': app_version, + 'wx-version': wx.VERSION_STRING, + 'wx-platform': wx.Platform, + 'python-version': platform.python_version(), # sys.version.split()[0], + 'platform': platform.platform(), + info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value) + last_tb = get_last_traceback(e_traceback) + exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred + info['locals'] = format_namespace(exception_locals) + if 'self' in exception_locals: + info['self'] = format_namespace(exception_locals['self'].__dict__) + if not os.path.exists(path): + output = open(bug_report_path, 'w') + output.write(a + ":\n" + str(info[a]) + "\n\n") def handle_exception(e_type, e_value, e_traceback):
traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func
last_tb = get_last_traceback(e_traceback)
ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno)
if ex not in ignored_exceptions:
+ ignored_exceptions.append(ex)
- bug_report_path = path+os.sep+"bug_report_"+date.replace(':','-').replace(' ','_')+".txt"
- result = Display_Exception_Dialog(e_type,e_value,e_traceback,bug_report_path)
- ignored_exceptions.append(ex)
- 'app-title' : wx.GetApp().GetAppName(), # app_title
- 'app-version' : app_version,
- 'wx-version' : wx.VERSION_STRING,
- 'wx-platform' : wx.Platform,
- 'python-version' : platform.python_version(), #sys.version.split()[0],
- 'platform' : platform.platform(),
- info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value)
- last_tb = get_last_traceback(e_traceback)
- exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred
- info['locals'] = format_namespace(exception_locals)
- if 'self' in exception_locals:
- info['self'] = format_namespace(exception_locals['self'].__dict__)
- output = open(bug_report_path,'w')
- output.write(a+":\n"+str(info[a])+"\n\n")
+ bug_report_path = path + os.sep + "bug_report_" + date.replace(':', '-').replace(' ', '_') + ".txt" + save_bug_report(e_type, e_value, e_traceback, bug_report_path, date) + Display_Exception_Dialog(e_type, e_value, e_traceback, bug_report_path) #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
sys.excepthook = handle_exception