本文整理汇总了Python中IPython.core.debugger.Pdb.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Pdb.__init__方法的具体用法?Python Pdb.__init__怎么用?Python Pdb.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.core.debugger.Pdb
的用法示例。
在下文中一共展示了Pdb.__init__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import __init__ [as 别名]
def __init__(self, *args, **kwargs):
Pdb.__init__(self, *args, **kwargs)
self._ptcomp = None
self.pt_init()
示例2: __init__
# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self.skip = kwargs.get('skip', None)
Pdb.__init__(self, *args, **kwargs)
self.prompt = Pdbi.PROMPT
示例3: __init__
# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import __init__ [as 别名]
def __init__(self, addr="127.0.0.1", port=4444):
"""Initialize the socket and initialize pdb."""
# Backup stdin and stdout before replacing them by the socket handle
self.old_stdout = sys.stdout
self.old_stdin = sys.stdin
self.port = port
# Open a 'reusable' socket to let the webapp reload on the same port
self.skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.skt.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
self.skt.bind((addr, port))
self.skt.listen(1)
# Writes to stdout are forbidden in mod_wsgi environments
try:
sys.stderr.write("pdb is running on %s:%d\n"
% self.skt.getsockname())
except IOError:
pass
(clientsocket, address) = self.skt.accept()
handle = clientsocket.makefile('rw')
Pdb.__init__(self, color_scheme='Linux', completekey='tab',
stdin=FileObjectWrapper(handle, self.old_stdin),
stdout=FileObjectWrapper(handle, self.old_stdin))
handle.write("writing to handle")
def import_module(possible_modules, needed_module):
"""Make it more resilient to different versions of IPython and try to
find a module."""
count = len(possible_modules)
for module in possible_modules:
sys.stderr.write(module)
try:
return __import__(module, fromlist=[needed_module])
except ImportError:
count -= 1
if count == 0:
raise
possible_modules = ['IPython.terminal.ipapp', # Newer IPython
'IPython.frontend.terminal.ipapp'] # Older IPython
app = import_module(possible_modules, "TerminalIPythonApp")
TerminalIPythonApp = app.TerminalIPythonApp
possible_modules = ['IPython.terminal.embed', # Newer IPython
'IPython.frontend.terminal.embed'] # Older IPython
embed = import_module(possible_modules, "InteractiveShellEmbed")
InteractiveShellEmbed = embed.InteractiveShellEmbed
try:
get_ipython
except NameError:
# Build a terminal app in order to force ipython to load the
# configuration
ipapp = TerminalIPythonApp()
# Avoid output (banner, prints)
ipapp.interact = False
ipapp.initialize()
def_colors = ipapp.shell.colors
else:
# If an instance of IPython is already running try to get an instance
# of the application. If there is no TerminalIPythonApp instanciated
# the instance method will create a new one without loading the config.
# i.e: if we are in an embed instance we do not want to load the config.
ipapp = TerminalIPythonApp.instance()
shell = get_ipython()
def_colors = shell.colors
# Detect if embed shell or not and display a message
if isinstance(shell, InteractiveShellEmbed):
shell.write_err(
"\nYou are currently into an embedded ipython shell,\n"
"the configuration will not be loaded.\n\n"
)
self.rcLines += [line + '\n' for line in ipapp.exec_lines]
sys.stdout = sys.stdin = handle
OCCUPIED.claim(port, sys.stdout)
sys.stderr.write(str(self.rcLines))