示例#1
0
import byomkesh_bakshi
import logging

byomkesh_bakshi.hook()
logging.basicConfig()

logger = logging.getLogger(__name__)

logging.raiseExceptions = True

qux = 15


def foo(cb):
    qix = 20
    try:
        cb()
    except:
        logger.exception('callback failed')


def bar1():
    baz = 80.5
    logger.info('Hello')


def bar2():
    baz = 890.50
    logger.info('Hello', exc_info=True)

示例#2
0
import argparse
import imp
import os

from byomkesh_bakshi import interact, hook
hook()

parser = argparse.ArgumentParser(
    description='A Python REPL with better exceptions enabled',
    prog='python -m byomkesh_bakshi')
parser.add_argument('-q',
                    '--quiet',
                    help="don't show a banner",
                    action='store_true')
parser.add_argument('-i',
                    '--no-init',
                    dest='no_init',
                    help="don't load ~/.pyinit",
                    action='store_true')
args = parser.parse_args()

startup_file = os.getenv('PYTHONSTARTUP')
if not args.no_init and startup_file is not None:
    with open(startup_file, 'r') as fd:
        imp.load_module('pystartup', fd, startup_file,
                        ('.py', 'r', imp.PY_SOURCE))

interact(args.quiet)