How to use ipdb - 10 common examples

To help you get started, we’ve selected a few ipdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leapcode / bitmask-dev / tests / functional / features / environment.py View on Github external
def _debug_on_error(context, step):
    if context.config.userdata.getbool("debug"):
        try:
            import ipdb
            ipdb.post_mortem(step.exc_traceback)
        except ImportError:
            import pdb
            pdb.post_mortem(step.exc_traceback)
github hal3 / macarico / tests / test_vw.py View on Github external
def debug_on_assertion(type, value, tb):
    if hasattr(sys, 'ps1') or not sys.stderr.isatty() or type != AssertionError:
        sys.__excepthook__(type, value, tb)
    else:
        import traceback, ipdb
        traceback.print_exception(type, value, tb)
        print()
        ipdb.pm()
github nicfit / eyeD3 / eyed3 / main.py View on Github external
eyed3.utils.console.printError(f"Uncaught exception: {ex}\n")
        eyed3.log.exception(ex)
        retval = 1

        if args.debug_pdb:
            try:
                with warnings.catch_warnings():
                    warnings.simplefilter("ignore", PendingDeprecationWarning)
                    # Must delay the import of ipdb as say as possible because
                    # of https://github.com/gotcha/ipdb/issues/48
                    import ipdb as pdb  # noqa
            except ImportError:
                import pdb  # noqa

            e, m, tb = sys.exc_info()
            pdb.post_mortem(tb)

    sys.exit(retval)
github facebookexperimental / eden / edenscm / mercurial / dispatch.py View on Github external
and not ui.pageractive
            and not ui.plain()
            and ui.formatted()
        ):
            ui.write_err(
                _(
                    "Starting ipdb for this exception\nIf you don't want the behavior, set devel.debugger to False\n"
                )
            )

            with demandimport.deactivated():
                import ipdb

            if not ui.tracebackflag:
                traceback.print_exc()
            ipdb.post_mortem(sys.exc_info()[2])
            os._exit(255)
        if not handlecommandexception(ui):
            raise

    return -1
github aldebaran / qibuild / python / qibuild / cmdparse.py View on Github external
"""This wraps the main method of an action so that:
       - backtrace is not printed by default
       - backtrace is printed is --backtrace was given
       - a pdb session is run if --pdb was given
    """
    try:
        module.do(args)
    except Exception as e:
        if args.pdb:
            traceback = sys.exc_info()[2]
            print ""
            print "### Exception:", e
            print "### Starting a debugger"
            try:
                import ipdb
                ipdb.post_mortem(traceback)
                sys.exit(0)
            except ImportError:
                import pdb
                pdb.post_mortem(traceback)
                sys.exit(0)
        if args.backtrace:
            raise
        logger = logging.getLogger("\n") # small hack
        logger.error(str(e))
        sys.exit(2)
github facebookexperimental / eden / eden / scm / edenscm / mercurial / dispatch.py View on Github external
debugtrace[debugger]()
            try:
                return _dispatch(req)
            finally:
                ui.flush()
        except:  # re-raises
            # Potentially enter the debugger when we hit an exception
            startdebugger = req.earlyoptions["debugger"]
            if startdebugger:
                # Enforce the use of ipdb, since it's always available and
                # we can afford the import overhead here.
                with demandimport.deactivated():
                    import ipdb

                traceback.print_exc()
                ipdb.post_mortem(sys.exc_info()[2])
                os._exit(255)
            raise
github facebookexperimental / eden / edenscm / mercurial / dispatch.py View on Github external
debugtrace[debugger]()
            try:
                return _dispatch(req)
            finally:
                ui.flush()
        except:  # re-raises
            # Potentially enter the debugger when we hit an exception
            startdebugger = req.earlyoptions["debugger"]
            if startdebugger:
                # Enforce the use of ipdb, since it's always available and
                # we can afford the import overhead here.
                with demandimport.deactivated():
                    import ipdb

                traceback.print_exc()
                ipdb.post_mortem(sys.exc_info()[2])
                os._exit(255)
            raise
github ipipdotnet / ipdb-python / example.py View on Github external
def test_city_ipv6_test():

    db = ipdb.City("c:/work/ipdb/mydata6vipday2.ipdb")

    print(db.find("2001:44c8:4644:1191:3c41:724d:e391:51b0", "CN"))
    print(db.find_map("2a04:3543:1000:2310:ecb3:3eff:fef0:20e1", "CN"))
    print(db.find_info("2a04:3543:1000:2310:ecb3:3eff:fef0:20e1", "CN").country_name)
github Phype / telnet-iot-honeypot / backend / clientcontroller.py View on Github external
	@db_wrapper
	def fill_db_ipranges(self):		
		if self.session.query(IPRange.ip_min).count() != 0:
			return
		
		print "Filling IPRange Tables"
		
		asntable = ipdb.ipdb.get_asn()
		progress = 0
		
		for row in ipdb.ipdb.get_geo_iter():
			progress += 1
			if progress % 1000 == 0:
				self.session.commit()
				self.session.flush()
				print str(100.0 * float(row[0]) / 4294967296.0) + "% / " + str(100.0 * progress / 3315466) + "%" 
			
			ip = IPRange(ip_min = int(row[0]), ip_max=int(row[1]))
			
			ip.country   = row[2]
			ip.region    = row[4]
			ip.city      = row[5]
			ip.zipcode   = row[8]
			ip.timezone  = row[9]
github Phype / telnet-iot-honeypot / backend / clientcontroller.py View on Github external
	@db_wrapper
	def fill_db_ipranges(self):		
		if self.session.query(IPRange.ip_min).count() != 0:
			return
		
		print "Filling IPRange Tables"
		
		asntable = ipdb.ipdb.get_asn()
		progress = 0
		
		for row in ipdb.ipdb.get_geo_iter():
			progress += 1
			if progress % 1000 == 0:
				self.session.commit()
				self.session.flush()
				print str(100.0 * float(row[0]) / 4294967296.0) + "% / " + str(100.0 * progress / 3315466) + "%" 
			
			ip = IPRange(ip_min = int(row[0]), ip_max=int(row[1]))
			
			ip.country   = row[2]
			ip.region    = row[4]
			ip.city      = row[5]
			ip.zipcode   = row[8]
			ip.timezone  = row[9]
			ip.latitude  = float(row[6])
			ip.longitude = float(row[7])