Start an IPython embed

        Calling embed won't do anything in a multithread context

        The stack_depth will be found automatically
164572
def embed(self, title=''):
        
        if self.embed_disabled:
            self.warning_log("Embed is disabled when runned from the grid runner because of the multithreading")  # noqa
            return False

        from IPython.terminal.embed import InteractiveShellEmbed

        if BROME_CONFIG['runner']['play_sound_on_ipython_embed']:
            say(BROME_CONFIG['runner']['sound_on_ipython_embed'])

        ipshell = InteractiveShellEmbed(banner1=title)

        frame = currentframe()
        stack_depth = 1
        for i in range(5):
            frame = frame.f_back
            stack_depth += 1
            if frame.f_code.co_filename not in __file__:
                break

        msg = 'Stopped at %s and line %s;' % \
            (frame.f_code.co_filename, frame.f_lineno)

        ipshell(msg, stack_depth=stack_depth)
705620
def pdb(self):
        
        if self.embed_disabled:
            self.warning_log("Pdb is disabled when runned from the grid runner because of the multithreading")  # noqa
            return False

        if BROME_CONFIG['runner']['play_sound_on_pdb']:
            say(BROME_CONFIG['runner']['sound_on_pdb'])

        set_trace()
588678
def discover_thread(callback,
                    timeout=5,
                    include_invisible=False,
                    interface_addr=None):
    
    thread = StoppableThread(
        target=_discover_thread,
        args=(callback, timeout, include_invisible, interface_addr))
    thread.start()
    return thread
1124641
def cur_depth_level(self):
        
        cur_level = self.initial_depth
        if not self.am_i_main_thread:
            cur_level += len(self.get_tasks(thread_name='MainThread'))

        return cur_level + len(self.tasks)
450302
def repl():
    """"""

    try:
        import IPython
    except:
        print("ERROR: IPython is not installed. Please install it to use the repl.", file=sys.stderr)
        raise

    IPython.embed(user_ns=dict(
        settings=oz.settings,
        actions=oz._actions,
        uimodules=oz._uimodules,
        routes=oz._routes,
    ))
1000548
def start_block(self,stylestack=None):
        
        if self.dirty:
            self.escpos._raw('\n')
            self.dirty = False
        self.stack.append('block')
        if stylestack:
            self.style(stylestack)
924899
def fix_embed_globals():
    
    frame = get_stack_frame(N=1)
    frame.f_globals.update(frame.f_locals)
    frame.f_globals['_did_embed_fix'] = True
    """
    def fix_embed_globals(N=0):
        import inspect
        # Get the parent frame
        frame_cur = inspect.currentframe()
        for _ix in range(N + 1):
            # always skip the frame of this function
            frame_next = frame_cur.f_back
            if frame_next is None:
                break
            frame_cur = frame_next
        # Add locals to parent globals
        frame = frame_cur
        frame.f_globals.update(frame.f_locals)
        frame.f_globals['_did_embed_fix'] = True
    """
164124
def invoke(cls, ns, banner):  # pragma: nocover
        
        try:
            from IPython.frontend.terminal.embed import (
                InteractiveShellEmbed
            )
            # try and load their default profile
            from IPython.frontend.terminal.ipapp import (
                load_default_config
            )
            config = load_default_config()
            shell = InteractiveShellEmbed(config=config, banner2=banner)
            shell(local_ns=ns)
        except ImportError:
            # Support for the IPython <= 0.10 shell API
            from IPython.Shell import IPShellEmbed
            shell = IPShellEmbed(argv=[])
            shell.set_banner(shell.IP.BANNER + '\n\n' + banner)
            shell(local_ns=ns, global_ns={})
873851
def on_stacktrace_request(self, py_db, request):
        '''
        
        '''
        # : :type stack_trace_arguments: StackTraceArguments
        stack_trace_arguments = request.arguments
        thread_id = stack_trace_arguments.threadId
        start_frame = stack_trace_arguments.startFrame
        levels = stack_trace_arguments.levels

        fmt = stack_trace_arguments.format
        if hasattr(fmt, 'to_dict'):
            fmt = fmt.to_dict()
        self.api.request_stack(py_db, request.seq, thread_id, fmt=fmt, start_frame=start_frame, levels=levels)
45347
def cli_main(pid, include_greenlet, debugger, verbose):
    '''
    '''
    try:
        print_stack(pid, include_greenlet, debugger, verbose)
    except DebuggerNotFound as e:
        click.echo('DebuggerNotFound: %s' % e.args[0], err=True)
        click.get_current_context().exit(1)
1259187
def debug(self, nest_level=1):
        

        prefix = '  ' * nest_level

        # This interacts with Any and moves the tag, implicit, explicit, _header,
        # contents, _footer to the parsed value so duplicate data isn't present
        has_parsed = hasattr(self, 'parsed')

        _basic_debug(prefix, self)
        if has_parsed:
            self.parsed.debug(nest_level + 2)
        elif hasattr(self, 'chosen'):
            self.chosen.debug(nest_level + 2)
        else:
            if _PY2 and isinstance(self.native, byte_cls):
                print('%s    Native: b%s' % (prefix, repr(self.native)))
            else:
                print('%s    Native: %s' % (prefix, self.native))
819148
def traverse_depth_first_post_order(self, callback):
        
        # a. Reimplement without python lists?..
        # b. Interface will require it to have not internal nodes only?..
        #    (but actually this implementation gives a ~2x gain of performance)
        last_interval = None
        n = len(self.suftab)
        stack = [[0, 0, None, []]]  # <l, i, j, children>
        for i in xrange(1, n):
            lb = i - 1
            while self.lcptab[i] < stack[-1][0]:
                stack[-1][2] = i - 1
                last_interval = stack.pop()
                callback(last_interval)
                lb = last_interval[1]
                if self.lcptab[i] <= stack[-1][0]:
                    stack[-1][3].append(last_interval)
                    last_interval = None
            if self.lcptab[i] > stack[-1][0]:
                if last_interval:
                    stack.append([self.lcptab[i], lb, None, [last_interval]])
                    last_interval = None
                else:
                    stack.append([self.lcptab[i], lb, None, []])
        stack[-1][2] = n - 1
        callback(stack[-1])
1243910
def start():
    
    os.write(BenchmarkProcess.BACKCHANNEL_OUT, BenchmarkProcess.START)
    response = util.untilConcludes(os.read, BenchmarkProcess.BACKCHANNEL_IN, 1)
    if response != BenchmarkProcess.START:
        raise RuntimeError(
            "Parent process responded with %r instead of START " % (response,))
141257
def run_pipeline_steps(steps, context):
    
    logger.debug("starting")
    assert isinstance(
        context, dict), "context must be a dictionary, even if empty {}."

    if steps is None:
        logger.debug("No steps found to execute.")
    else:
        step_count = 0

        for step in steps:
            step_instance = Step(step)
            step_instance.run_step(context)
            step_count += 1

        logger.debug(f"executed {step_count} steps")

    logger.debug("done")
688465
def main(argv=None):
	

	print("Ontospy " + ontospy.VERSION)
	ontospy.get_or_create_home_repo()

	if argv:
		print("Argument passing not implemented yet")
		if False:
			onto = Model(argv[0])
			for x in onto.get_classes():
				print(x)
			onto.buildPythonClasses()
			s = Sketch()

	else:

		intro = """Good morning. Ready to Turtle away. Type docs() for help."""
		# idea: every time provide a different ontology maxim!

		def docs():
			print("\n".join([x.strip() for x in Sketch.__doc__.splitlines()]))

		default_sketch = Sketch()

		def add(text=""):
			default_sketch.add(text)
		def show(aformat=None):
			if aformat:
				default_sketch.show(aformat)
			else:
				default_sketch.show()
		def bind(prefixTuple):
			default_sketch.bind(prefixTuple)
		def clear():
			default_sketch.clear()
		def omnigraffle():
			default_sketch.omnigraffle()


		try:
			# note: this requires IPython 0.11 or above
			import IPython
			IPython.embed(banner1=intro)
		except:
			import code
			code.interact(banner=intro, local=dict(globals(), **locals()))
	# finally
	sys.exit(0)
1167535
def send_caught_exception_stack_proceeded(self, thread):
        
        thread_id = get_thread_id(thread)
        int_cmd = InternalSendCurrExceptionTraceProceeded(thread_id)
        self.post_internal_command(int_cmd, thread_id)
        self.process_internal_commands()
246909
def __dump_stack(self):
        
        maxdepth = len(self._mode_stack)
        maxdepth_strlen = len(str(maxdepth))
        index_width = 4 - (-maxdepth_strlen) % 4 + 4
        index_str = lambda i: '{:<{}d}'.format(i, index_width)

        self.stdout.write(index_str(0) + self.root_prompt)
        self.stdout.write('\n')

        tree_prefix = '└── '
        for i in range(maxdepth):
            index_prefix = index_str(i + 1)
            whitespace_prefix = ' ' * len(tree_prefix) * i
            mode = self._mode_stack[i]
            line = index_prefix + whitespace_prefix + \
                    tree_prefix + mode.prompt + \
                    ': {}@{}'.format(mode.cmd, mode.args)
            self.stdout.write(line)
            self.stdout.write('\n')