Python pdb.pm() Examples

The following are 30 code examples for showing how to use pdb.pm(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module pdb , or try the search function .

Example 1
Project: cooltools   Author: mirnylab   File: __init__.py    License: MIT License 6 votes vote down vote up
def cli(verbose, debug):
    """
    Type -h or --help after any subcommand for more information.

    """
    if verbose:
        pass
        # logger.setLevel(logging.DEBUG)

    if debug:
        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 
Example 2
Project: ReAgent   Author: facebookresearch   File: debug_on_error.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def start():
    def info(type, value, tb):
        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, tb)
        else:
            import traceback
            import 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() # deprecated
            pdb.post_mortem(tb)  # more "modern"

    sys.excepthook = info 
Example 3
Project: jwalk   Author: jwplayer   File: __main__.py    License: Apache License 2.0 5 votes vote down vote up
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() 
Example 4
Project: link-prediction_with_deep-learning   Author: cambridgeltl   File: __main__.py    License: MIT License 5 votes vote down vote up
def debug(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() 
Example 5
Project: link-prediction_with_deep-learning   Author: cambridgeltl   File: __main__.py    License: MIT License 5 votes vote down vote up
def debug(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() 
Example 6
Project: exaddos   Author: Exa-Networks   File: debug.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def intercept (type, value, trace):
	interactive = os.environ.get('PDB',None)

	if interactive in ['0','']:
		# PDB was set to 0 or '' which is undocumented, and we do nothing
		pass
	else:
		bug_report(type, value, trace)
		if interactive == 'true':
			import pdb
			pdb.pm() 
Example 7
Project: polyglot   Author: aboSamoor   File: __main__.py    License: GNU General Public License v3.0 5 votes vote down vote up
def debug(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() 
Example 8
Project: Computable   Author: ktraunmueller   File: backend_wx.py    License: MIT License 5 votes vote down vote up
def debug_on_error(type, value, tb):
    """Code due to Thomas Heller - published in Python Cookbook (O'Reilley)"""
    traceback.print_exc(type, value, tb)
    print()
    pdb.pm()  # jdh uncomment 
Example 9
Project: Mastering-Elasticsearch-7.0   Author: PacktPublishing   File: backend_wx.py    License: MIT License 5 votes vote down vote up
def debug_on_error(type, value, tb):
    """Code due to Thomas Heller - published in Python Cookbook (O'Reilly)"""
    import pdb
    import traceback
    traceback.print_exception(type, value, tb)
    print()
    pdb.pm() 
Example 10
Project: matplotlib-4-abaqus   Author: Solid-Mechanics   File: backend_wx.py    License: MIT License 5 votes vote down vote up
def debug_on_error(type, value, tb):
    """Code due to Thomas Heller - published in Python Cookbook (O'Reilley)"""
    traceback.print_exc(type, value, tb)
    print()
    pdb.pm()  # jdh uncomment 
Example 11
Project: neural-network-animation   Author: miloharper   File: backend_wx.py    License: MIT License 5 votes vote down vote up
def debug_on_error(type, value, tb):
    """Code due to Thomas Heller - published in Python Cookbook (O'Reilley)"""
    traceback.print_exc(type, value, tb)
    print()
    pdb.pm()  # jdh uncomment 
Example 12
Project: GraphicDesignPatternByPython   Author: Relph1119   File: backend_wx.py    License: MIT License 5 votes vote down vote up
def debug_on_error(type, value, tb):
    """Code due to Thomas Heller - published in Python Cookbook (O'Reilley)"""
    traceback.print_exception(type, value, tb)
    print()
    pdb.pm()  # jdh uncomment 
Example 13
Project: python3_ios   Author: holzschu   File: backend_wx.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def debug_on_error(type, value, tb):
    """Code due to Thomas Heller - published in Python Cookbook (O'Reilley)"""
    traceback.print_exception(type, value, tb)
    print()
    pdb.pm()  # jdh uncomment 
Example 14
Project: Fluid-Designer   Author: Microvellum   File: pdb.py    License: GNU General Public License v3.0 5 votes vote down vote up
def pm():
    post_mortem(sys.last_traceback)


# Main program for testing 
Example 15
Project: beancount-import   Author: jbms   File: webserver.py    License: GNU General Public License v2.0 5 votes vote down vote up
def on_message(self, message):
        try:
            message = json.loads(message)
            f = getattr(self, 'on_message_%s' % message['type'], None)
            if f is None:
                raise TypeError('Invalid message type: %r' % message)
            self.application.ioloop.add_callback(f, message['value'])
        except:
            traceback.print_exc()
            pdb.pm() 
Example 16
Project: Imogen   Author: CedricGuillemet   File: pdb.py    License: MIT License 5 votes vote down vote up
def pm():
    post_mortem(sys.last_traceback)


# Main program for testing 
Example 17
Project: ironpython3   Author: IronLanguages   File: pdb.py    License: Apache License 2.0 5 votes vote down vote up
def pm():
    post_mortem(sys.last_traceback)


# Main program for testing 
Example 18
Project: pairtools   Author: mirnylab   File: __init__.py    License: MIT License 5 votes vote down vote up
def cli(post_mortem, output_profile):
    '''Flexible tools for Hi-C data processing.

    All pairtools have a few common options, which should be typed _before_ 
    the command name.

    '''
    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

    if output_profile:
        import cProfile 
        import atexit
        
        pr = cProfile.Profile()
        pr.enable()

        def _atexit_profile_hook():
            pr.disable()
            pr.dump_stats(output_profile)

        atexit.register(_atexit_profile_hook) 
Example 19
Project: everest   Author: rodluger   File: utils.py    License: MIT License 5 votes vote down vote up
def ExceptionHookPDB(exctype, value, tb):
    '''
    A custom exception handler, with :py:obj:`pdb` post-mortem for debugging.

    '''

    for line in traceback.format_exception_only(exctype, value):
        log.error(line.replace('\n', ''))
    for line in traceback.format_tb(tb):
        log.error(line.replace('\n', ''))
    sys.__excepthook__(exctype, value, tb)
    pdb.pm() 
Example 20
Project: google-apputils   Author: google   File: debug.py    License: Apache License 2.0 5 votes vote down vote up
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() 
Example 21
Project: ImageFusion   Author: pfchai   File: backend_wx.py    License: MIT License 5 votes vote down vote up
def debug_on_error(type, value, tb):
    """Code due to Thomas Heller - published in Python Cookbook (O'Reilley)"""
    traceback.print_exc(type, value, tb)
    print()
    pdb.pm()  # jdh uncomment 
Example 22
Project: TitleDB   Author: ksanislo   File: debug.py    License: The Unlicense 5 votes vote down vote up
def info(type, value, tb):
    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, tb)
    else:
        import traceback, pdb
        # we are NOT in interactive mode, print the exceptionceback.print_exception(type, value, tb)
        print
        #tart the debugger in post-mortem mode.
        # pdb.pm() # deprecated
        pdb.post_mortem(tb) # more "modern" 
Example 23
Project: langchangetrack   Author: viveksck   File: dummy_regressor.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def debug(type_, value, tb):
    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, tb)
    else:
        import traceback
        import pdb
        # we are NOT in interactive mode, print the exception...
        traceback.print_exception(type_, value, tb)
        print("\n")
        # ...then start the debugger in post-mortem mode.
        pdb.pm() 
Example 24
Project: langchangetrack   Author: viveksck   File: pos_tag.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def debug(type_, value, tb):
    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, tb)
    else:
        import traceback
        import pdb
        # we are NOT in interactive mode, print the exception...
        traceback.print_exception(type_, value, tb)
        print("\n")
        # ...then start the debugger in post-mortem mode.
        pdb.pm() 
Example 25
Project: langchangetrack   Author: viveksck   File: common_vocab.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def debug(type_, value, tb):
    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, tb)
    else:
        import traceback
        import pdb
        # we are NOT in interactive mode, print the exception...
        traceback.print_exception(type_, value, tb)
        print("\n")
        # ...then start the debugger in post-mortem mode.
        pdb.pm() 
Example 26
Project: langchangetrack   Author: viveksck   File: freq_count.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def debug(type_, value, tb):
    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, tb)
    else:
        import traceback
        import pdb
        # we are NOT in interactive mode, print the exception...
        traceback.print_exception(type_, value, tb)
        print("\n")
        # ...then start the debugger in post-mortem mode.
        pdb.pm() 
Example 27
def debug(type_, value, tb):
    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, tb)
    else:
        import traceback
        import pdb
        # we are NOT in interactive mode, print the exception...
        traceback.print_exception(type_, value, tb)
        print("\n")
        # ...then start the debugger in post-mortem mode.
        pdb.pm() 
Example 28
Project: OpenHINE   Author: BUPTDM   File: HERec.py    License: MIT License 5 votes vote down vote up
def debug(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() 
Example 29
Project: Project-New-Reign---Nemesis-Main   Author: ShikyoKira   File: pdb.py    License: GNU General Public License v3.0 5 votes vote down vote up
def pm():
    post_mortem(sys.last_traceback)


# Main program for testing 
Example 30
Project: faucet   Author: faucetsdn   File: clib_mininet_test_main.py    License: Apache License 2.0 5 votes vote down vote up
def debug_exception_handler(etype, value, trace):
    import traceback
    import pdb
    traceback.print_exception(etype, value, trace)
    print()
    pdb.pm()