PLCOpenEditor.py
changeset 1740 b789b695b5c6
parent 1739 ec153828ded2
child 1741 dd94b9a68c61
equal deleted inserted replaced
1739:ec153828ded2 1740:b789b695b5c6
   403 #-------------------------------------------------------------------------------
   403 #-------------------------------------------------------------------------------
   404 
   404 
   405 Max_Traceback_List_Size = 20
   405 Max_Traceback_List_Size = 20
   406 
   406 
   407 
   407 
   408 def Display_Exception_Dialog(e_type,e_value,e_tb):
   408 def Display_Exception_Dialog(e_type, e_value, e_tb):
   409     trcbck_lst = []
   409     trcbck_lst = []
   410     for i,line in enumerate(traceback.extract_tb(e_tb)):
   410     for i, line in enumerate(traceback.extract_tb(e_tb)):
   411         trcbck = " " + str(i+1) + _(". ")
   411         trcbck = " " + str(i+1) + _(". ")
   412         if line[0].find(os.getcwd()) == -1:
   412         if line[0].find(os.getcwd()) == -1:
   413             trcbck += _("file : ") + str(line[0]) + _(",   ")
   413             trcbck += _("file : ") + str(line[0]) + _(",   ")
   414         else:
   414         else:
   415             trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(",   ")
   415             trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(",   ")
   470         last_tb = get_last_traceback(e_traceback)
   470         last_tb = get_last_traceback(e_traceback)
   471         ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno)
   471         ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno)
   472         if str(e_value).startswith("!!!"):
   472         if str(e_value).startswith("!!!"):
   473             Display_Error_Dialog(e_value)
   473             Display_Error_Dialog(e_value)
   474         elif ex not in ignored_exceptions:
   474         elif ex not in ignored_exceptions:
   475             result = Display_Exception_Dialog(e_type,e_value,e_traceback)
   475             result = Display_Exception_Dialog(e_type, e_value, e_traceback)
   476             if result:
   476             if result:
   477                 ignored_exceptions.append(ex)
   477                 ignored_exceptions.append(ex)
   478                 info = {
   478                 info = {
   479                     'app-title': wx.GetApp().GetAppName(),  # app_title
   479                     'app-title': wx.GetApp().GetAppName(),  # app_title
   480                     'app-version': app_version,
   480                     'app-version': app_version,
   493                     exception_locals = last_tb.tb_frame.f_locals  # the locals at the level of the stack trace where the exception actually occurred
   493                     exception_locals = last_tb.tb_frame.f_locals  # the locals at the level of the stack trace where the exception actually occurred
   494                     info['locals'] = format_namespace(exception_locals)
   494                     info['locals'] = format_namespace(exception_locals)
   495                     if 'self' in exception_locals:
   495                     if 'self' in exception_locals:
   496                         info['self'] = format_namespace(exception_locals['self'].__dict__)
   496                         info['self'] = format_namespace(exception_locals['self'].__dict__)
   497 
   497 
   498                 output = open(path+os.sep+"bug_report_"+time.strftime("%Y_%m_%d__%H-%M-%S")+".txt",'w')
   498                 output = open(path+os.sep+"bug_report_"+time.strftime("%Y_%m_%d__%H-%M-%S")+".txt", 'w')
   499                 lst = info.keys()
   499                 lst = info.keys()
   500                 lst.sort()
   500                 lst.sort()
   501                 for a in lst:
   501                 for a in lst:
   502                     output.write(a+":\n"+str(info[a])+"\n\n")
   502                     output.write(a+":\n"+str(info[a])+"\n\n")
   503 
   503