Python pdb 模块,pm() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用pdb.pm()

项目:sysl    作者:anz-bank    | 项目源码 | 文件源码
def _hook(type_, value, tback):
    """Exception hook callback."""
    if hasattr(sys, 'ps1') or not sys.stderr.isatty():
        # we are in interactive mode or we don't have a tty-like
        # device, so we call the default hook
        sys.__excepthook__(type_, value, tback)
    else:
        import traceback
        import pdb
        # we are NOT in interactive mode, print the exception...
        traceback.print_exception(type_, value, tback)

        # Dirty hack because Py27 doesn't chain exceptions
        if value.args:
            tb2 = value.args[-1]
            if isinstance(tb2, type(tback)):
                ex = value.args[-2]
                print >>sys.stderr, '{}Caused by{} '.format(
                    ansi('1;35m'), ansi('0m')),
                traceback.print_exception(type_(ex), ex, tb2)

            print
        # ...then start the debugger in post-mortem mode.
        # pdb.pm() # deprecated
        pdb.post_mortem(tback)  # more "modern"
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def pm():
    post_mortem(sys.last_traceback)


# Main program for testing
项目:jwalk    作者:jwplayer    | 项目源码 | 文件源码
def debug_hook(type_, value, tb):
    if hasattr(sys, 'ps1') or not sys.stderr.isatty():
        sys.__excepthook__(type_, value, tb)
    else:
        import traceback
        import pdb
        traceback.print_exception(type_, value, tb)
        print(u"\n")
        pdb.pm()
项目:protoc-gen-lua-bin    作者:u0u0    | 项目源码 | 文件源码
def _DebugHandler(exc_class, value, tb):
  if not flags.FLAGS.pdb or hasattr(sys, 'ps1') or not sys.stderr.isatty():
    # we aren't in interactive mode or we don't have a tty-like
    # device, so we call the default hook
    old_excepthook(exc_class, value, tb)
  else:
    # Don't impose import overhead on apps that never raise an exception.
    import traceback
    import pdb
    # we are in interactive mode, print the exception...
    traceback.print_exception(exc_class, value, tb)
    sys.stdout.write('\n')
    # ...then start the debugger in post-mortem mode.
    pdb.pm()
项目:protoc-gen-lua-bin    作者:u0u0    | 项目源码 | 文件源码
def _DebugHandler(exc_class, value, tb):
  if not flags.FLAGS.pdb or hasattr(sys, 'ps1') or not sys.stderr.isatty():
    # we aren't in interactive mode or we don't have a tty-like
    # device, so we call the default hook
    old_excepthook(exc_class, value, tb)
  else:
    # Don't impose import overhead on apps that never raise an exception.
    import traceback
    import pdb
    # we are in interactive mode, print the exception...
    traceback.print_exception(exc_class, value, tb)
    sys.stdout.write('\n')
    # ...then start the debugger in post-mortem mode.
    pdb.pm()
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def pm():
    post_mortem(sys.last_traceback)


# Main program for testing
项目:Simulator    作者:libsmelt    | 项目源码 | 文件源码
def info(type, value, tb):
   if hasattr(sys, 'ps1') or not sys.stderr.isatty() or type != AssertionError:
      # we are in interactive mode or we don't have a tty-like
      # device, so we call the default hook
      sys.__excepthook__(type, value, tb)
   else:
      import traceback, pdb
      # we are NOT in interactive mode, print the exception...
      traceback.print_exception(type, value, tb)
      print
      # ...then start the debugger in post-mortem mode.
      pdb.pm()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def pm():
    post_mortem(sys.last_traceback)


# Main program for testing
项目:cookiecutter-pypackage    作者:ksindi    | 项目源码 | 文件源码
def debug_hook(type_, value, tb):
    # http://stackoverflow.com/a/1237407/690430
    if hasattr(sys, 'ps1') or not sys.stderr.isatty():
        sys.__excepthook__(type_, value, tb)
    else:
        import traceback
        import pdb
        traceback.print_exception(type_, value, tb)
        print(u"\n")
        pdb.pm()
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def pm():
    post_mortem(sys.last_traceback)


# Main program for testing
项目:pairsamtools    作者:mirnylab    | 项目源码 | 文件源码
def cli(post_mortem):
    if post_mortem:
        import traceback
        try:
            import ipdb as pdb
        except ImportError:
            import pdb
        def _excepthook(exc_type, value, tb):
            traceback.print_exception(exc_type, value, tb)
            print()
            pdb.pm()
        sys.excepthook = _excepthook
项目:yam    作者:trichter    | 项目源码 | 文件源码
def run(command, conf=None, tutorial=False, pdb=False, **args):
    """Main entry point for a direct call from Python

    Example usage:

    >>> from yam import run
    >>> run(conf='conf.json')

    :param command: if ``'create'`` the example configuration is created,
       optionally the tutorial data files are downloaded

    For all other commands this function loads the configuration
    and construct the arguments which are passed to `run2()`

    All args correspond to the respective command line and
    configuration options.
    See the example configuration file for help and possible arguments.
    Options in args can overwrite the configuration from the file.
    E.g. ``run(conf='conf.json', bla='bla')`` will set bla configuration
    value to ``'bla'``.
    """
    if pdb:
        import traceback, pdb

        def info(type, value, tb):
            traceback.print_exception(type, value, tb)
            print
            # ...then start the debugger in post-mortem mode.
            pdb.pm()

        sys.excepthook = info
    if conf in ('None', 'none', 'null', ''):
        conf = None
    # Copy example files if create_config or tutorial
    if command == 'create':
        if conf is None:
            conf = 'conf.json'
        create_config(conf, tutorial=tutorial)
        return
    # Parse config file
    if conf:
        try:
            with open(conf) as f:
                conf = json.load(f, cls=ConfigJSONDecoder)
        except ValueError as ex:
            msg = 'Error while parsing the configuration: %s' % ex
            raise ConfigError(msg)
        except IOError as ex:
            raise ConfigError(ex)
        # Populate args with conf, but prefer args
        conf.update(args)
        args = conf
    run2(command, **args)