Exemplo n.º 1
0
def debug_shell(user_ns, user_global_ns, execWrapper=None):
	ipshell = None
	if not ipshell:
		# old? doesn't work anymore. but probably has earlier, so leave it
		try:
			from IPython.Shell import IPShellEmbed,IPShell
			ipshell = IPShell(argv=[], user_ns=user_ns, user_global_ns=user_global_ns)
			ipshell = ipshell.mainloop
		except Exception: pass
	if not ipshell:
		try:
			import IPython
			class DummyMod(object): pass
			module = DummyMod()
			module.__dict__ = user_global_ns
			module.__name__ = "DummyMod"
			ipshell = IPython.frontend.terminal.embed.InteractiveShellEmbed(
				user_ns=user_ns, user_module=module)
		except Exception: pass
		else:
			if execWrapper:
				old = ipshell.run_code
				ipshell.run_code = lambda code: execWrapper(lambda: old(code))
	if ipshell:
		ipshell()
	else:
		simple_debug_shell(user_global_ns, user_ns)						
Exemplo n.º 2
0
def debug_shell(user_ns, user_global_ns, execWrapper=None):
    ipshell = None
    if not ipshell:
        # old? doesn't work anymore. but probably has earlier, so leave it
        try:
            from IPython.Shell import IPShellEmbed, IPShell
            ipshell = IPShell(argv=[],
                              user_ns=user_ns,
                              user_global_ns=user_global_ns)
            ipshell = ipshell.mainloop
        except Exception:
            pass
    if not ipshell:
        try:
            import IPython

            class DummyMod(object):
                pass

            module = DummyMod()
            module.__dict__ = user_global_ns
            module.__name__ = "DummyMod"
            ipshell = IPython.frontend.terminal.embed.InteractiveShellEmbed(
                user_ns=user_ns, user_module=module)
        except Exception:
            pass
        else:
            if execWrapper:
                old = ipshell.run_code
                ipshell.run_code = lambda code: execWrapper(lambda: old(code))
    if ipshell:
        ipshell()
    else:
        simple_debug_shell(user_global_ns, user_ns)