def __init__(self, colors=None): """Create a local debugger instance. :Parameters: - `colors` (None): a string containing the name of the color scheme to use, it must be one of IPython's valid color schemes. If not given, the function will default to the current IPython scheme when running inside IPython, and to 'NoColor' otherwise. Usage example: from IPython.Debugger import Tracer; debug_here = Tracer() ... later in your code debug_here() # -> will open up the debugger at that point. Once the debugger activates, you can use all of its regular commands to step through code, set breakpoints, etc. See the pdb documentation from the Python standard library for usage details. """ global __IPYTHON__ try: __IPYTHON__ except NameError: # Outside of ipython, we set our own exception hook manually __IPYTHON__ = ipapi.get(True, False) BdbQuit_excepthook.excepthook_ori = sys.excepthook sys.excepthook = BdbQuit_excepthook def_colors = 'NoColor' try: # Limited tab completion support import rlcompleter, readline readline.parse_and_bind('tab: complete') except ImportError: pass else: # In ipython, we use its custom exception handler mechanism ip = ipapi.get() def_colors = ip.options.colors ip.set_custom_exc((bdb.BdbQuit, ), BdbQuit_IPython_excepthook) if colors is None: colors = def_colors self.debugger = Pdb(colors) #additions for pydebug from util import Utilities self.util = Utilities(None) #save xid so that we can return to it after the pdb sesion self.xid = self.util.get_xid()
def __init__(self, handle): #handle object contains command line inputs to this activity self.handle = handle _logger.debug('Activity id:%s.Object id: %s. uri:%s' % (handle.activity_id, handle.object_id, handle.uri)) self.passed_in_ds_object = None if handle.object_id and handle.object_id != '': self.passed_in_ds_object = datastore.get(handle.object_id) if self.passed_in_ds_object: d = self.passed_in_ds_object.metadata #log_dict(d,'initial datastore metadata ==>:') else: ds_object = self.get_new_dsobject() if hasattr(ds_object, 'get_object_id'): handle.object_id = ds_object.get_object_id() else: handle.object_id = ds_object.object_id _logger.debug( 'no initial datastore object id passed in via handle') #Save a global poiinter so remote procedure calls can communicate with pydebug global pydebug_instance pydebug_instance = self start_clock = time.clock() #init variables self.make_paths() self.save_icon_clicked = False self.source_directory = None self.data_file = None self.help = None self.help_x11 = None self.dirty = False self.sock = None #self.last_filename = None self.debug_dict = {} self.activity_dict = {} self.manifest_treeview = None #set up to recognize an re-display of playpen #self.set_title(_('PyDebug Activity')) self.ds = None #datastore pointer self._logger = _logger self.traceback = 'Context' self.abandon_changes = False self.delete_after_load = None self.find_window = None self.icon_outline = 'icon_square' self.icon_window = None self.last_icon_file = None self.activity_data_changed = False self.icon_basename = None #sugar 0.82 has a different way of getting colors and dies during init unless the following self.profile = profile.get_profile() self.profile.color = XoColor() #get the persistent data across all debug sessions and start using it self.get_config() #give the server a chance to get started so terminal can connect to it self.non_blocking_server() #glib.idle_add(self.non_blocking_server) """ if self.request_new_jobject and self.debug_dict.get('jobject_id','') != '': self.request_new_jobject = False #keep on using the same journal entry if self.debug_dict.get('jobject_id','') != '': handle.object_id = self.debug_dict.get('jobject_id','') """ # init the Classes we are subclassing _logger.debug('about to init superclass activity. Elapsed time: %f'%\ (time.clock()-start_clock)) Activity.__init__(self, handle, create_jobject=False) """ if self.request_new_jobject: #check to see if the object was created if self._jobject: self.debug_dict['jobject_id'] = str(self._jobject.object_id) else: _logger.debug('failed to create jobject in Activity.__init__') """ self.connect('realize', self.realize_cb) self.accelerator = gtk.AccelGroup() self.add_accel_group(self.accelerator) #set up the PANES for the different functions of the debugger _logger.debug('about to set up Menu panes. Elapsed time: %f' % (time.clock() - start_clock)) self.panes = {} PANES = ['TERMINAL', 'EDITOR', 'PROJECT', 'HELP'] for i in range(len(PANES)): self.panes[PANES[i]] = i #toolbox needs to be available during init of modules self.toolbox = pytoolbar.ActivityToolbox(self) self.toolbox.connect_after('current_toolbar_changed', self._toolbar_changed_cb) self.toolbox.set_current_toolbar(self.panes['TERMINAL']) ######################################################################################### #init the sub functions TerminalGui.__init__(self, self, self.toolbox) EditorGui.__init__(self, self) ProjectGui.__init__(self, self) self.help = Help(self) self.util = Utilities(self) ######################################################################################### #if first time run on this machine, set up home directory if not os.path.isfile(os.path.join(self.debugger_home, '.bashrc')): self.setup_home_directory() # setup the search options self.s_opts = SearchOptions( where=S_WHERE.file, use_regex=False, ignore_caps=True, replace_all=False, #defaults to avoid creating #a new SearchOptions object for normal searches #should never be changed, just make a copy like: #SearchOptions(self.s_opts, forward=False) forward=True, stay=False) self.safe_to_replace = False #get the sugar version (major, minor, micro, release) = self._activity.util.sugar_version() _logger.debug('sugar version major:%s minor:%s micro:%s release:%s' % (major, minor, micro, release)) if not minor: minor = 70 self.sugar_minor = minor ######################################################################################### _logger.debug( 'All app objects created. about to set up Display . Elapsed time: %f' % (time.clock() - start_clock)) self.canvas_list = [] self.canvas_list.append(self._get_terminal_canvas()) self.canvas_list.append(self._get_edit_canvas()) self.canvas_list.append(self._get_project_canvas()) self.canvas_list.append(self._get_help_canvas()) nb = gtk.Notebook() nb.show() nb.set_show_tabs(False) for c in self.canvas_list: nb.append_page(c) self.pydebug_notebook = nb #the following call to the activity code puts our notebook under the stock toolbar self.set_canvas(nb) helpbar = self.help.get_help_toolbar() self.toolbox.add_toolbar(_('Edit'), self.get_editbar()) self.toolbox.add_toolbar(_('Project'), self.get_projectbar()) self.toolbox.add_toolbar(_('Help'), self.help.get_help_toolbar()) self.set_toolbox(self.toolbox) self.toolbox.show() #set which PANE is visible initially self.set_visible_canvas(self.panes['PROJECT']) self.set_toolbar(self.panes['PROJECT']) _logger.debug('about to setup_project_page. Elapsed time: %f' % (time.clock() - start_clock)) self.setup_project_page() _logger.debug( 'about Returned from setup_project_page. Elapsed time: %f' % (time.clock() - start_clock)) #get the journal datastore information and resume previous activity #self.metadata = self.ds if self.passed_in_ds_object and self.passed_in_ds_object.get_file_path( ): ds_file = self.passed_in_ds_object.get_file_path() else: ds_file = '' _logger.debug('about to call read routine Elapsed time: %f' % (time.clock() - start_clock)) self.read_file(ds_file) _logger.debug('about (end of init) Elapsed time: %f' % (time.clock() - start_clock))