PLCOpenEditor.py
changeset 1736 7e61baa047f0
parent 1734 750eeb7230a1
child 1737 a39c2918c015
equal deleted inserted replaced
1735:c02818d7e29f 1736:7e61baa047f0
    91 #-------------------------------------------------------------------------------
    91 #-------------------------------------------------------------------------------
    92 
    92 
    93 # Define PLCOpenEditor FileMenu extra items id
    93 # Define PLCOpenEditor FileMenu extra items id
    94 [ID_PLCOPENEDITORFILEMENUGENERATE,
    94 [ID_PLCOPENEDITORFILEMENUGENERATE,
    95 ] = [wx.NewId() for _init_coll_FileMenu_Items in range(1)]
    95 ] = [wx.NewId() for _init_coll_FileMenu_Items in range(1)]
       
    96 
    96 
    97 
    97 class PLCOpenEditor(IDEFrame):
    98 class PLCOpenEditor(IDEFrame):
    98 
    99 
    99     # Compatibility function for wx versions < 2.6
   100     # Compatibility function for wx versions < 2.6
   100     if wx.VERSION < (2, 6, 0):
   101     if wx.VERSION < (2, 6, 0):
   401 #                               Exception Handler
   402 #                               Exception Handler
   402 #-------------------------------------------------------------------------------
   403 #-------------------------------------------------------------------------------
   403 
   404 
   404 Max_Traceback_List_Size = 20
   405 Max_Traceback_List_Size = 20
   405 
   406 
       
   407 
   406 def Display_Exception_Dialog(e_type,e_value,e_tb):
   408 def Display_Exception_Dialog(e_type,e_value,e_tb):
   407     trcbck_lst = []
   409     trcbck_lst = []
   408     for i,line in enumerate(traceback.extract_tb(e_tb)):
   410     for i,line in enumerate(traceback.extract_tb(e_tb)):
   409         trcbck = " " + str(i+1) + _(". ")
   411         trcbck = " " + str(i+1) + _(". ")
   410         if line[0].find(os.getcwd()) == -1:
   412         if line[0].find(os.getcwd()) == -1:
   439     finally:
   441     finally:
   440         dlg.Destroy()
   442         dlg.Destroy()
   441 
   443 
   442     return res
   444     return res
   443 
   445 
       
   446 
   444 def Display_Error_Dialog(e_value):
   447 def Display_Error_Dialog(e_value):
   445     message = wx.MessageDialog(None, str(e_value), _("Error"), wx.OK|wx.ICON_ERROR)
   448     message = wx.MessageDialog(None, str(e_value), _("Error"), wx.OK|wx.ICON_ERROR)
   446     message.ShowModal()
   449     message.ShowModal()
   447     message.Destroy()
   450     message.Destroy()
   448 
   451 
       
   452 
   449 def get_last_traceback(tb):
   453 def get_last_traceback(tb):
   450     while tb.tb_next:
   454     while tb.tb_next:
   451         tb = tb.tb_next
   455         tb = tb.tb_next
   452     return tb
   456     return tb
   453 
   457 
   455 def format_namespace(d, indent='    '):
   459 def format_namespace(d, indent='    '):
   456     return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()])
   460     return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()])
   457 
   461 
   458 
   462 
   459 ignored_exceptions = [] # a problem with a line in a module is only reported once per session
   463 ignored_exceptions = [] # a problem with a line in a module is only reported once per session
       
   464 
   460 
   465 
   461 def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]):
   466 def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]):
   462 
   467 
   463     def handle_exception(e_type, e_value, e_traceback):
   468     def handle_exception(e_type, e_value, e_traceback):
   464         traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func
   469         traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func