def __init__(self, host=CELERY_RDB_HOST, port=CELERY_RDB_PORT, port_search_limit=100, port_skew=+0, out=sys.stdout): self.active = True self.out = out self._prev_handles = sys.stdin, sys.stdout self._sock, this_port = self.get_avail_port(host, port, port_search_limit, port_skew) self._sock.listen(1) me = "%s:%s" % (self.me, this_port) context = self.context = {"me": me, "host": host, "port": this_port} self.say("%(me)s: Please telnet %(host)s %(port)s." " Type `exit` in session to continue." % context) self.say("%(me)s: Waiting for client..." % context) self._client, address = self._sock.accept() context["remote_addr"] = ":".join(map(str, address)) self.say("%(me)s: In session with %(remote_addr)s" % context) self._handle = sys.stdin = sys.stdout = self._client.makefile("rw") Pdb.__init__(self, completekey="tab", stdin=self._handle, stdout=self._handle)
def __init__(self, host=CELERY_RDB_HOST, port=CELERY_RDB_PORT, port_search_limit=100, port_skew=+0, out=sys.stdout): self.active = True self.out = out self._prev_handles = sys.stdin, sys.stdout self._sock, this_port = self.get_avail_port( host, port, port_search_limit, port_skew, ) self._sock.setblocking(1) self._sock.listen(1) me = '%s:%s' % (self.me, this_port) context = self.context = {'me': me, 'host': host, 'port': this_port} self.say('%(me)s: Please telnet %(host)s %(port)s.' ' Type `exit` in session to continue.' % context) self.say('%(me)s: Waiting for client...' % context) self._client, address = self._sock.accept() self._client.setblocking(1) context['remote_addr'] = ':'.join(str(v) for v in address) self.say('%(me)s: In session with %(remote_addr)s' % context) self._handle = sys.stdin = sys.stdout = self._client.makefile('rw') Pdb.__init__(self, completekey='tab', stdin=self._handle, stdout=self._handle)
def listen(self): if not self._quiet: cry("RemotePdb session open at %s:%s, " "use 'ray debug' to connect..." % self._listen_socket.getsockname()) self._listen_socket.listen(1) connection, address = self._listen_socket.accept() if not self._quiet: cry("RemotePdb accepted connection from %s." % repr(address)) self.handle = LF2CRLF_FileWrapper(connection) Pdb.__init__(self, completekey="tab", stdin=self.handle, stdout=self.handle) self.backup = [] if self._patch_stdstreams: for name in ( "stderr", "stdout", "__stderr__", "__stdout__", "stdin", "__stdin__", ): self.backup.append((name, getattr(sys, name))) setattr(sys, name, self.handle) RemotePdb.active_instance = self
def __init__(self, host, port, patch_stdstreams=False): listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) listen_socket.bind((host, port)) cry("RemotePdb session open at %s:%s, waiting for connection ..." % listen_socket.getsockname()) listen_socket.listen(1) connection, address = listen_socket.accept() cry("RemotePdb accepted connection from %s." % repr(address)) if PY3: self.handle = LF2CRLF_FileWrapper(connection.makefile('rw')) else: self.handle = LF2CRLF_FileWrapper(connection.makefile()) Pdb.__init__(self, completekey='tab', stdin=self.handle, stdout=self.handle) self.backup = [] if patch_stdstreams: for name in ( 'stderr', 'stdout', '__stderr__', '__stdout__', 'stdin', '__stdin__', ): self.backup.append((name, getattr(sys, name))) setattr(sys, name, self.handle) RemotePdb.active_instance = self
def __init__(self, *args, **kwargs): Pdb.__init__(self, *args, **kwargs) self.botframe = None self.quitting = False self.stopframe = None self.codemap = {} self.entered = False
def __init__(self): Pdb.__init__(self) self.capturing = False config = getConfiguration() self.to_vim = ProxyToVim(config) self.from_vim = ProxyFromVim(config) self._textOutput = ''
def __init__(self, host='', port=5555, patch_stdstreams=False): """ :param host: web-UI hostname or IP-address :type host: str :param port: web-UI port. If ``port=-1``, choose a random port value between 32768 and 65536. :type port: int :param patch_stdstreams: redirect all standard input and output streams to the web-UI. :type patch_stdstreams: bool """ if port == -1: random.seed() port = random.randint(32768, 65536) self.console = WebConsole(host, port, self) Pdb.__init__(self, stdin=self.console, stdout=self.console) # Borrowed from here: https://github.com/ionelmc/python-remote-pdb self._backup = [] if patch_stdstreams: for name in ( 'stderr', 'stdout', '__stderr__', '__stdout__', 'stdin', '__stdin__', ): self._backup.append((name, getattr(sys, name))) setattr(sys, name, self.console) WebPdb.active_instance = self
def __init__(self): self.stepping = True self.command = '' self.lineno = 666 self.calls = [] self.first = True Pdb.__init__(self)
def __init__(self, tcbk): Pdb.__init__(self) self.reset() while tcbk.tb_next is not None: tcbk = tcbk.tb_next self._tcbk = tcbk self._histfile = osp.join(os.environ["HOME"], ".pdbhist")
def __init__(self, color_scheme=None, completekey=None, stdin=None, stdout=None, context=5): # Parent constructor: try: self.context = int(context) if self.context <= 0: raise ValueError("Context must be a positive integer") except (TypeError, ValueError): raise ValueError("Context must be a positive integer") OldPdb.__init__(self, completekey, stdin, stdout) # IPython changes... self.shell = get_ipython() if self.shell is None: # No IPython instance running, we must create one from IPython.terminal.interactiveshell import TerminalInteractiveShell self.shell = TerminalInteractiveShell.instance() if color_scheme is not None: warnings.warn("The `color_scheme` argument is deprecated since version 5.1", DeprecationWarning) else: color_scheme = self.shell.colors self.aliases = {} # Create color table: we copy the default one from the traceback # module and add a few attributes needed for debugging self.color_scheme_table = exception_colors() # shorthands C = coloransi.TermColors cst = self.color_scheme_table cst["NoColor"].colors.prompt = C.NoColor cst["NoColor"].colors.breakpoint_enabled = C.NoColor cst["NoColor"].colors.breakpoint_disabled = C.NoColor cst["Linux"].colors.prompt = C.Green cst["Linux"].colors.breakpoint_enabled = C.LightRed cst["Linux"].colors.breakpoint_disabled = C.Red cst["LightBG"].colors.prompt = C.Blue cst["LightBG"].colors.breakpoint_enabled = C.LightRed cst["LightBG"].colors.breakpoint_disabled = C.Red cst["Neutral"].colors.prompt = C.Blue cst["Neutral"].colors.breakpoint_enabled = C.LightRed cst["Neutral"].colors.breakpoint_disabled = C.Red self.set_colors(color_scheme) # Add a python parser so we can syntax highlight source while # debugging. self.parser = PyColorize.Parser() # Set the prompt - the default prompt is '(Pdb)' self.prompt = prompt
def __init__(self, host=CELERY_RDB_HOST, port=CELERY_RDB_PORT, port_search_limit=100, port_skew=+0, out=sys.stdout): self.active = True self.out = out self._prev_handles = sys.stdin, sys.stdout self._sock, this_port = self.get_avail_port( host, port, port_search_limit, port_skew, ) self._sock.setblocking(1) self._sock.listen(1) self.ident = '{0}:{1}'.format(self.me, this_port) self.host = host self.port = this_port self.say(BANNER.format(self=self)) self._client, address = self._sock.accept() self._client.setblocking(1) self.remote_addr = ':'.join(str(v) for v in address) self.say(SESSION_STARTED.format(self=self)) self._handle = sys.stdin = sys.stdout = self._client.makefile('rw') Pdb.__init__(self, completekey='tab', stdin=self._handle, stdout=self._handle)
def __init__(self, tcbk=None): Pdb.__init__(self) self.reset() if tcbk: while tcbk.tb_next is not None: tcbk = tcbk.tb_next self._tcbk = tcbk self._histfile = os.path.expanduser("~/.pdbhist")
def __init__(self,color_scheme='NoColor',completekey=None, stdin=None, stdout=None, context=5): # Parent constructor: try: self.context=int(context) if self.context <= 0: raise ValueError("Context must be a positive integer") except (TypeError, ValueError): raise ValueError("Context must be a positive integer") OldPdb.__init__(self,completekey,stdin,stdout) # IPython changes... self.shell = get_ipython() if self.shell is None: # No IPython instance running, we must create one from IPython.terminal.interactiveshell import \ TerminalInteractiveShell self.shell = TerminalInteractiveShell.instance() self.aliases = {} # Create color table: we copy the default one from the traceback # module and add a few attributes needed for debugging self.color_scheme_table = exception_colors() # shorthands C = coloransi.TermColors cst = self.color_scheme_table cst['NoColor'].colors.prompt = C.NoColor cst['NoColor'].colors.breakpoint_enabled = C.NoColor cst['NoColor'].colors.breakpoint_disabled = C.NoColor cst['Linux'].colors.prompt = C.Green cst['Linux'].colors.breakpoint_enabled = C.LightRed cst['Linux'].colors.breakpoint_disabled = C.Red cst['LightBG'].colors.prompt = C.Blue cst['LightBG'].colors.breakpoint_enabled = C.LightRed cst['LightBG'].colors.breakpoint_disabled = C.Red self.set_colors(color_scheme) # Add a python parser so we can syntax highlight source while # debugging. self.parser = PyColorize.Parser() # Set the prompt - the default prompt is '(Pdb)' Colors = cst.active_colors if color_scheme == 'NoColor': self.prompt = prompt else: # The colour markers are wrapped by bytes 01 and 02 so that readline # can calculate the width. self.prompt = u'\x01%s\x02%s\x01%s\x02' % (Colors.prompt, prompt, Colors.Normal)
def __init__(self, color_scheme='NoColor', completekey=None, stdin=None, stdout=None, context=5): # Parent constructor: try: self.context = int(context) if self.context <= 0: raise ValueError("Context must be a positive integer") except (TypeError, ValueError): raise ValueError("Context must be a positive integer") OldPdb.__init__(self, completekey, stdin, stdout) # IPython changes... self.shell = get_ipython() if self.shell is None: # No IPython instance running, we must create one from IPython.terminal.interactiveshell import \ TerminalInteractiveShell self.shell = TerminalInteractiveShell.instance() self.aliases = {} # Create color table: we copy the default one from the traceback # module and add a few attributes needed for debugging self.color_scheme_table = exception_colors() # shorthands C = coloransi.TermColors cst = self.color_scheme_table cst['NoColor'].colors.prompt = C.NoColor cst['NoColor'].colors.breakpoint_enabled = C.NoColor cst['NoColor'].colors.breakpoint_disabled = C.NoColor cst['Linux'].colors.prompt = C.Green cst['Linux'].colors.breakpoint_enabled = C.LightRed cst['Linux'].colors.breakpoint_disabled = C.Red cst['LightBG'].colors.prompt = C.Blue cst['LightBG'].colors.breakpoint_enabled = C.LightRed cst['LightBG'].colors.breakpoint_disabled = C.Red self.set_colors(color_scheme) # Add a python parser so we can syntax highlight source while # debugging. self.parser = PyColorize.Parser() # Set the prompt - the default prompt is '(Pdb)' self.prompt = prompt
def __init__(self, endcallback): Pdb.__init__(self) # completely reinitialize breakpoints since they sometimes seem # to get stuck Breakpoint.next = 1 Breakpoint.bplist = {} Breakpoint.bpbynumber = [None] self._endcallback = endcallback # do not display any prompt self.prompt = '' # get input lines from our fake input stream self.stdin = FakeStdin()
def __init__(self, port=8787): # pdb server self.skt = socket(AF_INET, SOCK_STREAM) self.skt.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.skt.bind(('0.0.0.0', port)) self.skt.listen(1) # listen for debugger client self.client, self.client_addr = self.skt.accept() self.client_io = self.client.makefile('rw') print 'Rpdb(%s:%s) debugger: starting.' % self.client_addr # init pdb Pdb.__init__(self, stdin=self.client_io, stdout=self.client_io)
def __init__(self, port=8787): # pdb server self.skt = socket(AF_INET, SOCK_STREAM) self.skt.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.skt.bind(('0.0.0.0', port)) self.skt.listen(1) # listen for debugger client self.client , self.client_addr = self.skt.accept() self.client_io = self.client.makefile('rw') print 'Rpdb(%s:%s) debugger: starting.' % self.client_addr # init pdb Pdb.__init__(self, stdin=self.client_io, stdout=self.client_io)
def __init__(self): Pdb.__init__(self) self.proto = Proto() self.c_stdout = self.stdout #crunchy output self.stdout = MyStringIO(self.stdout) #eat up everything output by orginal pdb self.prompt = "" #remove prompt self.use_rawinput = 0 #these name should not be exposed to user (as they are used by pdb) self.exclude_name_list = ['__return__', '__exception__']#, '__builtins__'] self.last_locals = {}
def __init__(self, host='127.0.0.1', port=4444, patch_stdstreams=False, quiet=False, unix_socket_file=None): self._quiet = quiet if unix_socket_file: socket_type = socket.AF_UNIX else: socket_type = socket.AF_INET listen_socket = socket.socket(socket_type, socket.SOCK_STREAM) if not unix_socket_file: listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) listen_socket.bind((host, port)) else: listen_socket.bind(unix_socket_file) if not self._quiet: if unix_socket_file: cry("RemotePdb session open at %s, waiting for connection ..." % unix_socket_file) else: cry("RemotePdb session open at %s:%s, waiting for connection ..." % listen_socket.getsockname()) listen_socket.listen(1) connection, address = listen_socket.accept() if not self._quiet: if unix_socket_file: cry("RemotePdb accepted connection from %s." % unix_socket_file) else: cry("RemotePdb accepted connection from %s." % repr(address)) self.handle = LF2CRLF_FileWrapper(connection) Pdb.__init__(self, completekey='tab', stdin=self.handle, stdout=self.handle) self.backup = [] if patch_stdstreams: for name in ( 'stderr', 'stdout', '__stderr__', '__stdout__', 'stdin', '__stdin__', ): self.backup.append((name, getattr(sys, name))) setattr(sys, name, self.handle) RemotePdb.active_instance = self
def __init__(self, host, port): self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.connect((host, port)) print("SocketPdb session open at %s:%s" % self.socket.getsockname()) if is_python_3: self.handle = self.socket.makefile('rw') else: self.handle = self.socket.makefile() self.handle.write("\n*********************\n") self.handle.write("PDB debugger opening\n") Pdb.__init__(self, completekey='tab', stdin=self.handle, stdout=self.handle)
def __init__(self): Pdb.__init__(self) self.proto = Proto() self.c_stdout = self.stdout #crunchy output self.stdout = MyStringIO( self.stdout) #eat up everything output by orginal pdb self.prompt = "" #remove prompt self.use_rawinput = 0 #these name should not be exposed to user (as they are used by pdb) self.exclude_name_list = ['__return__', '__exception__'] #, '__builtins__'] self.last_locals = {}
def __init__(self, port=8787, suspend=True): self.con = Condition() # pdb server self.skt = socket(AF_INET, SOCK_STREAM) self.skt.setsockopt(SOL_SOCKET, SO_REUSEADDR, True) self.skt.bind(('0.0.0.0', port)) self.skt.listen(1) self._listen() # debug io self.io = RpdbIO() self.debugging = False self.suspend = suspend # init pdb Pdb.__init__(self, stdin=self.io, stdout=self.io)
def set_trace(self, *args, **kwargs): """Start a pdb debugger available via telnet, and optionally email people the endpoint The endpoint will always be seen in the py.test runner output. Keyword Args: recipients: A list where, if set, an email will be sent to email addresses in this list. subject: If set, an optional custom email subject """ host, port = self.sock.getsockname() endpoint = 'host {} port {}'.format(store.my_ip_address, port) recipients = kwargs.pop('recipients', None) if recipients: # write and send an email subject = kwargs.pop('subject', 'RDB Breakpoint: Manually invoked') body = dedent("""\ A py.test run encountered an error. The remote debugger is running on {} (TCP), waiting for telnet connection. """).format(endpoint) try: smtp_server = smtp_conf['server'] smtp = smtplib.SMTP(smtp_server) msg = MIMEText(body) msg['Subject'] = subject msg['To'] = ', '.join(recipients) smtp.sendmail('*****@*****.**', recipients, msg.as_string()) except socket.error: logger.critical("Couldn't send email") msg = 'Remote debugger listening on {}'.format(endpoint) logger.critical(msg) write_line(msg, red=True, bold=True) self.sock.listen(1) (client_socket, address) = self.sock.accept() client_fh = client_socket.makefile('rw') Pdb.__init__(self, completekey='tab', stdin=client_fh, stdout=client_fh) sys.stdout = sys.stdin = client_fh Pdb.set_trace(self, *args, **kwargs) msg = 'Debugger on {} shut down'.format(endpoint) logger.critical(msg) write_line(msg, green=True, bold=True)
def __init__(self, host='', port=5555): """ :param host: web-UI hostname or IP-address :type host: str :param port: web-UI port. If ``port=-1``, choose a random port value between 32768 and 65536. :type port: int :param patch_stdstreams: redirect all standard input and output streams to the web-UI. :type patch_stdstreams: bool """ if port == -1: random.seed() port = random.randint(32768, 65536) self.console = WebConsole(host, port, self) Pdb.__init__(self, stdin=self.console, stdout=self.console) WebPdb.active_instance = self
def __init__(self, host=CELERY_RDB_HOST, port=CELERY_RDB_PORT, port_search_limit=100, port_skew=+0, out=sys.stdout): self.active = True self.out = out self._prev_handles = sys.stdin, sys.stdout self._sock, this_port = self.get_avail_port(host, port, port_search_limit, port_skew) self._sock.listen(1) self.ident = "{0}:{1}".format(self.me, this_port) self.host = host self.port = this_port self.say(BANNER.format(self=self)) self._client, address = self._sock.accept() self.remote_addr = ":".join(imap(str, address)) self.say(SESSION_STARTED.format(self=self)) self._handle = sys.stdin = sys.stdout = self._client.makefile("rw") Pdb.__init__(self, completekey="tab", stdin=self._handle, stdout=self._handle)
def __init__(self, host=SDB_HOST, port=SDB_PORT, notify_host=SDB_NOTIFY_HOST, context_lines=SDB_CONTEXT_LINES, port_search_limit=100, port_skew=+0, out=sys.stdout, colorize=SDB_COLORIZE, interactive=False): self.active = True self.out = out self.colorize = colorize self._prev_handles = sys.stdin, sys.stdout self.notify_host = notify_host self.context_lines = int(context_lines) self._sock, this_port = self.get_avail_port( host, port, port_search_limit, port_skew, ) self._sock.setblocking(1) self._sock.listen(1) self.host = host self.port = this_port self.ident = '{0}:{1}'.format(self.me, this_port) self.interactive = interactive if self.interactive is False: self.say(BANNER.format(self=self)) self._client, address = self._sock.accept() self._client.setblocking(1) self.remote_addr = ':'.join(str(v) for v in address) self.say(SESSION_STARTED.format(self=self)) self._handle = sys.stdin = sys.stdout = self._client.makefile('rw') Pdb.__init__(self, stdin=self._handle, stdout=self._handle) else: Pdb.__init__(self, stdin=sys.stdin, stdout=sys.stdout) self.prompt = ''
def __init__(self, host, port, patch_stdstreams=False): cry('listen socket') self._listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._listen_socket.settimeout(None) cry('setsokcport') self._listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) cry('bind') self._listen_socket.bind((host, port)) self._stop_monitor = threading.Event() self._monitor_thread = threading.Thread(target=self._monitor_abort) self._monitor_thread.daemon = True self._monitor_thread.start() if not host: host = socket.gethostname() port = self._listen_socket.getsockname()[1] cry("RemotePdb session open at %s:%s, waiting for connection ..." % (host, port)) self._dialog = DialogProgressBG() self._dialog.create('remote-pdb', 'Waiting for connection at [COLOR=yellow]%s:%s[/COLOR]' % (host, port) ) self._listen_socket.listen(1) self._connection, address = self._listen_socket.accept() self._connection.settimeout(None) self._dialog.update(100, heading='remote-pdb', message='Connection from %s active' % address[0]) cry("RemotePdb accepted connection from %s." % repr(address)) if PY3: self.handle = LF2CRLF_FileWrapper(self._connection.makefile('rw')) else: self.handle = LF2CRLF_FileWrapper(self._connection.makefile()) Pdb.__init__(self, completekey='tab', stdin=self.handle, stdout=self.handle) self.backup = [] if patch_stdstreams: for name in ( 'stderr', 'stdout', '__stderr__', '__stdout__', 'stdin', '__stdin__', ): self.backup.append((name, getattr(sys, name))) setattr(sys, name, self.handle) RemotePdb.active_instance = self
def __init__(self, host, port, patch_stdstreams=False): listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) listen_socket.bind((host, port)) cry("RemotePdb session open at %s:%s, waiting for connection ..." % listen_socket.getsockname()) listen_socket.listen(1) connection, address = listen_socket.accept() cry("RemotePdb accepted connection from %s." % repr(address)) if PY3: # Some versions of Python 3.6, 3.7 and 3.8 have errors with makefile in rw mode # This redirects the write calls to the underlying socket as a workaround # See https://bugs.python.org/issue35928 for tracking of the fix filelike = connection.makefile('r') def write_override(data): data = data.encode(filelike.encoding) connection.send(data) self.handle = LF2CRLF_FileWrapper(filelike, write_override=write_override) else: self.handle = LF2CRLF_FileWrapper(connection.makefile()) Pdb.__init__(self, completekey='tab', stdin=self.handle, stdout=self.handle) self.backup = [] if patch_stdstreams: for name in ( 'stderr', 'stdout', '__stderr__', '__stdout__', 'stdin', '__stdin__', ): self.backup.append((name, getattr(sys, name))) setattr(sys, name, self.handle) RemotePdb.active_instance = self
def __init__(self, host, port, patch_stdstreams=False): listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) listen_socket.bind((host, port)) listen_socket.listen(1) connection, address = listen_socket.accept() self.handle = LF2CRLF_FileWrapper(connection) Pdb.__init__(self, completekey='tab', stdin=self.handle, stdout=self.handle) self.backup = [] if patch_stdstreams: for name in ( 'stderr', 'stdout', '__stderr__', '__stdout__', 'stdin', '__stdin__', ): self.backup.append((name, getattr(sys, name))) setattr(sys, name, self.handle) RemotePdb.active_instance = self
def __init__(self, color_scheme=None, completekey=None, stdin=None, stdout=None, context=5, **kwargs): """Create a new IPython debugger. Parameters ---------- color_scheme : default None Deprecated, do not use. completekey : default None Passed to pdb.Pdb. stdin : default None Passed to pdb.Pdb. stdout : default None Passed to pdb.Pdb. context : int Number of lines of source code context to show when displaying stacktrace information. **kwargs Passed to pdb.Pdb. Notes ----- The possibilities are python version dependent, see the python docs for more info. """ # Parent constructor: try: self.context = int(context) if self.context <= 0: raise ValueError("Context must be a positive integer") except (TypeError, ValueError) as e: raise ValueError("Context must be a positive integer") from e # `kwargs` ensures full compatibility with stdlib's `pdb.Pdb`. OldPdb.__init__(self, completekey, stdin, stdout, **kwargs) # IPython changes... self.shell = get_ipython() if self.shell is None: save_main = sys.modules['__main__'] # No IPython instance running, we must create one from IPython.terminal.interactiveshell import \ TerminalInteractiveShell self.shell = TerminalInteractiveShell.instance() # needed by any code which calls __import__("__main__") after # the debugger was entered. See also #9941. sys.modules["__main__"] = save_main if color_scheme is not None: warnings.warn( "The `color_scheme` argument is deprecated since version 5.1", DeprecationWarning, stacklevel=2) else: color_scheme = self.shell.colors self.aliases = {} # Create color table: we copy the default one from the traceback # module and add a few attributes needed for debugging self.color_scheme_table = exception_colors() # shorthands C = coloransi.TermColors cst = self.color_scheme_table cst['NoColor'].colors.prompt = C.NoColor cst['NoColor'].colors.breakpoint_enabled = C.NoColor cst['NoColor'].colors.breakpoint_disabled = C.NoColor cst['Linux'].colors.prompt = C.Green cst['Linux'].colors.breakpoint_enabled = C.LightRed cst['Linux'].colors.breakpoint_disabled = C.Red cst['LightBG'].colors.prompt = C.Blue cst['LightBG'].colors.breakpoint_enabled = C.LightRed cst['LightBG'].colors.breakpoint_disabled = C.Red cst['Neutral'].colors.prompt = C.Blue cst['Neutral'].colors.breakpoint_enabled = C.LightRed cst['Neutral'].colors.breakpoint_disabled = C.Red # Add a python parser so we can syntax highlight source while # debugging. self.parser = PyColorize.Parser(style=color_scheme) self.set_colors(color_scheme) # Set the prompt - the default prompt is '(Pdb)' self.prompt = prompt self.skip_hidden = True self.report_skipped = True # list of predicates we use to skip frames self._predicates = self.default_predicates
def __init__(self, color_scheme=None, completekey=None, stdin=None, stdout=None, context=5): # Parent constructor: try: self.context = int(context) if self.context <= 0: raise ValueError("Context must be a positive integer") except (TypeError, ValueError): raise ValueError("Context must be a positive integer") OldPdb.__init__(self, completekey, stdin, stdout) # IPython changes... self.shell = get_ipython() if self.shell is None: save_main = sys.modules['__main__'] # No IPython instance running, we must create one from IPython.terminal.interactiveshell import \ TerminalInteractiveShell self.shell = TerminalInteractiveShell.instance() # needed by any code which calls __import__("__main__") after # the debugger was entered. See also #9941. sys.modules['__main__'] = save_main if color_scheme is not None: warnings.warn( "The `color_scheme` argument is deprecated since version 5.1", DeprecationWarning) else: color_scheme = self.shell.colors self.aliases = {} # Create color table: we copy the default one from the traceback # module and add a few attributes needed for debugging self.color_scheme_table = exception_colors() # shorthands C = coloransi.TermColors cst = self.color_scheme_table cst['NoColor'].colors.prompt = C.NoColor cst['NoColor'].colors.breakpoint_enabled = C.NoColor cst['NoColor'].colors.breakpoint_disabled = C.NoColor cst['Linux'].colors.prompt = C.Green cst['Linux'].colors.breakpoint_enabled = C.LightRed cst['Linux'].colors.breakpoint_disabled = C.Red cst['LightBG'].colors.prompt = C.Blue cst['LightBG'].colors.breakpoint_enabled = C.LightRed cst['LightBG'].colors.breakpoint_disabled = C.Red cst['Neutral'].colors.prompt = C.Blue cst['Neutral'].colors.breakpoint_enabled = C.LightRed cst['Neutral'].colors.breakpoint_disabled = C.Red self.set_colors(color_scheme) # Add a python parser so we can syntax highlight source while # debugging. self.parser = PyColorize.Parser() # Set the prompt - the default prompt is '(Pdb)' self.prompt = prompt
def __init__(self, to_vim, from_vim): Pdb.__init__(self) self.capturing = False self.to_vim = to_vim self.from_vim = from_vim self._textOutput = ''
def __init__(self, exit_hook: Callable[[], None]): self._exit_hook = exit_hook Pdb.__init__(self)
raise Exception( "%s: Could not find available port. Please set using " "environment variable CELERY_RDB_PORT" % (self.me, )) self._sock.listen(1) me = "%s:%s" % (self.me, this_port) context = self.context = {"me": me, "host": host, "port": this_port} print("%(me)s: Please telnet %(host)s %(port)s." " Type `exit` in session to continue." % context) print("%(me)s: Waiting for client..." % context) self._client, address = self._sock.accept() context["remote_addr"] = ":".join(map(str, address)) print("%(me)s: In session with %(remote_addr)s" % context) self._handle = sys.stdin = sys.stdout = self._client.makefile("rw") Pdb.__init__(self, completekey="tab", stdin=self._handle, stdout=self._handle) def _close_session(self): self.stdin, self.stdout = sys.stdin, sys.stdout = self._prev_handles self._handle.close() self._client.close() self._sock.close() self.active = False print("%(me)s: Session %(remote_addr)s ended." % self.context) def do_continue(self, arg): self._close_session() self.set_continue() return 1 do_c = do_cont = do_continue
def __init__(self, color_scheme=None, completekey=None, stdin=None, stdout=None, context=5): # Parent constructor: try: self.context = int(context) if self.context <= 0: raise ValueError("Context must be a positive integer") except (TypeError, ValueError): raise ValueError("Context must be a positive integer") OldPdb.__init__(self, completekey, stdin, stdout) # yap_ipython changes... self.shell = get_ipython() if self.shell is None: save_main = sys.modules['__main__'] # No yap_ipython instance running, we must create one from yap_ipython.terminal.interactiveshell import \ TerminalInteractiveShell self.shell = TerminalInteractiveShell.instance() # needed by any code which calls __import__("__main__") after # the debugger was entered. See also #9941. sys.modules['__main__'] = save_main if color_scheme is not None: warnings.warn( "The `color_scheme` argument is deprecated since version 5.1", DeprecationWarning, stacklevel=2) else: color_scheme = self.shell.colors self.aliases = {} # Create color table: we copy the default one from the traceback # module and add a few attributes needed for debugging self.color_scheme_table = exception_colors() # shorthands C = coloransi.TermColors cst = self.color_scheme_table cst['NoColor'].colors.prompt = C.NoColor cst['NoColor'].colors.breakpoint_enabled = C.NoColor cst['NoColor'].colors.breakpoint_disabled = C.NoColor cst['Linux'].colors.prompt = C.Green cst['Linux'].colors.breakpoint_enabled = C.LightRed cst['Linux'].colors.breakpoint_disabled = C.Red cst['LightBG'].colors.prompt = C.Blue cst['LightBG'].colors.breakpoint_enabled = C.LightRed cst['LightBG'].colors.breakpoint_disabled = C.Red cst['Neutral'].colors.prompt = C.Blue cst['Neutral'].colors.breakpoint_enabled = C.LightRed cst['Neutral'].colors.breakpoint_disabled = C.Red # Add a python parser so we can syntax highlight source while # debugging. self.parser = PyColorize.Parser(style=color_scheme) self.set_colors(color_scheme) # Set the prompt - the default prompt is '(Pdb)' self.prompt = prompt
"%s: Could not find available port. Please set using " "environment variable CELERY_RDB_PORT" % (self.me, )) self._sock.listen(1) me = "%s:%s" % (self.me, this_port) context = self.context = {"me": me, "host": host, "port": this_port} print("%(me)s: Please telnet %(host)s %(port)s." " Type `exit` in session to continue." % context) print("%(me)s: Waiting for client..." % context) self._client, address = self._sock.accept() context["remote_addr"] = ":".join(map(str, address)) print("%(me)s: In session with %(remote_addr)s" % context) self._handle = sys.stdin = sys.stdout = self._client.makefile("rw") Pdb.__init__(self, completekey="tab", stdin=self._handle, stdout=self._handle) def _close_session(self): self.stdin, self.stdout = sys.stdin, sys.stdout = self._prev_handles self._handle.close() self._client.close() self._sock.close() self.active = False print("%(me)s: Session %(remote_addr)s ended." % self.context) def do_continue(self, arg): self._close_session() self.set_continue() return 1
def __init__(self, view): Pdb.__init__(self) self.view = view