예제 #1
0
파일: __main__.py 프로젝트: ltddev/wdb
def main():
    """Wdb entry point"""
    sys.path.insert(0, os.getcwd())
    args, extrargs = parser.parse_known_args()
    sys.argv = ['wdb'] + extrargs

    if args.file:
        file = os.path.join(os.getcwd(), args.file)
        if args.source:
            print('The source argument cannot be used with file.')
            sys.exit(1)

        if not os.path.exists(file):
            print('Error:', file, 'does not exist')
            sys.exit(1)

        Wdb.get().run_file(file)
    else:
        source = None
        if args.source:
            source = os.path.join(os.getcwd(), args.source)
            if not os.path.exists(source):
                print('Error:', source, 'does not exist')
                sys.exit(1)

        Wdb.get().shell(source)
예제 #2
0
async def run_file(file_name: str) -> None:  # pragma: no cover
    """
    Function for run file debug
    """
    # pylint: disable=import-outside-toplevel
    from wdb import Wdb  # isort:skip

    Wdb.get().run_file(file_name)
예제 #3
0
async def run_shell() -> None:  # pragma: no cover
    """
    Function for run shell(debug)
    """
    # pylint: disable=import-outside-toplevel
    from wdb import Wdb  # isort:skip

    Wdb.get().shell()
예제 #4
0
파일: __main__.py 프로젝트: Avinash9/wdb
def main():
    """Inspired by python -m pdb. Debug any python script with wdb"""
    if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
        print("usage: wdb.py scriptfile [arg] ...")
        sys.exit(2)

    mainpyfile = sys.argv[1]
    if not os.path.exists(mainpyfile):
        print('Error:', mainpyfile, 'does not exist')
        sys.exit(1)

    del sys.argv[0]
    sys.path[0] = os.path.dirname(mainpyfile)

    Wdb.get().run_file(mainpyfile)
예제 #5
0
def main():
    """Inspired by python -m pdb. Debug any python script with wdb"""
    if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
        print("usage: wdb.py scriptfile [arg] ...")
        sys.exit(2)

    mainpyfile = sys.argv[1]
    if not os.path.exists(mainpyfile):
        print('Error:', mainpyfile, 'does not exist')
        sys.exit(1)

    del sys.argv[0]
    sys.path[0] = os.path.dirname(mainpyfile)

    Wdb.get().run_file(mainpyfile)
예제 #6
0
    def _wdb_execute(*args, **kwargs):
        from wdb import trace, Wdb

        if Wdb.enabled:
            wdb = Wdb.get()
            wdb.closed = False  # Activate request ignores

        interesting = True
        if len(args) > 0 and isinstance(args[0], ErrorHandler):
            interesting = False
        elif (len(args) > 2 and isinstance(args[0], StaticFileHandler)
              and args[2] == 'favicon.ico'):
            interesting = False

        if Wdb.enabled and interesting:
            with trace(close_on_exit=True, under=under):
                old_execute(*args, **kwargs)
        else:
            old_execute(*args, **kwargs)
            # Close set_trace debuggers
            stop_trace(close_on_exit=True)

        if Wdb.enabled:
            # Reset closed state
            wdb.closed = False
예제 #7
0
파일: ext.py 프로젝트: niziou/wdb
 def f():
     # Enable wdb
     wdb = Wdb.get()
     Wdb.enabled = True
     start_response('200 OK', [
         ('Content-Type', 'text/html'), ('X-Thing', wdb.uuid)])
     yield to_bytes(' ' * 4096)
     wdb = set_trace()
     wdb.die()
     yield to_bytes('Exited')
예제 #8
0
파일: ext.py 프로젝트: minisin/wdb
 def f():
     # Enable wdb
     wdb = Wdb.get()
     Wdb.enabled = True
     start_response('200 OK', [('Content-Type', 'text/html'),
                               ('X-Thing', wdb.uuid)])
     yield to_bytes(' ' * 4096)
     wdb = set_trace()
     wdb.die()
     yield to_bytes('Exited')
예제 #9
0
def main():
    """Wdb entry point"""
    sys.path.insert(0, os.getcwd())
    args, extrargs = parser.parse_known_args()
    sys.argv = ['wdb'] + args.args + extrargs

    if args.file:
        file = os.path.join(os.getcwd(), args.file)
        if args.source:
            print('The source argument cannot be used with file.')
            sys.exit(1)

        if not os.path.exists(file):
            print('Error:', file, 'does not exist')
            sys.exit(1)
        if args.trace:
            Wdb.get().run_file(file)
        else:

            def wdb_pm(xtype, value, traceback):
                sys.__excepthook__(xtype, value, traceback)
                wdb = Wdb.get()
                wdb.reset()
                wdb.interaction(None, traceback, post_mortem=True)

            sys.excepthook = wdb_pm

            with open(file) as f:
                code = compile(f.read(), file, 'exec')
                execute(code, globals(), globals())

    else:
        source = None
        if args.source:
            source = os.path.join(os.getcwd(), args.source)
            if not os.path.exists(source):
                print('Error:', source, 'does not exist')
                sys.exit(1)

        Wdb.get().shell(source)
예제 #10
0
파일: __main__.py 프로젝트: Kozea/wdb
def main():
    """Wdb entry point"""
    sys.path.insert(0, os.getcwd())
    args, extrargs = parser.parse_known_args()
    sys.argv = ['wdb'] + args.args + extrargs

    if args.file:
        file = os.path.join(os.getcwd(), args.file)
        if args.source:
            print('The source argument cannot be used with file.')
            sys.exit(1)

        if not os.path.exists(file):
            print('Error:', file, 'does not exist')
            sys.exit(1)
        if args.trace:
            Wdb.get().run_file(file)
        else:

            def wdb_pm(xtype, value, traceback):
                sys.__excepthook__(xtype, value, traceback)
                wdb = Wdb.get()
                wdb.reset()
                wdb.interaction(None, traceback, post_mortem=True)

            sys.excepthook = wdb_pm

            with open(file) as f:
                code = compile(f.read(), file, 'exec')
                execute(code, globals(), globals())

    else:
        source = None
        if args.source:
            source = os.path.join(os.getcwd(), args.source)
            if not os.path.exists(source):
                print('Error:', source, 'does not exist')
                sys.exit(1)

        Wdb.get().shell(source)
예제 #11
0
파일: ext.py 프로젝트: niziou/wdb
 def trace_wsgi(environ, start_response):
     wdb = Wdb.get()
     wdb.closed = False
     appiter = None
     try:
         with trace(close_on_exit=True, under=self.app):
             appiter = self.app(environ, start_response)
             for item in appiter:
                 yield item
     except Exception:
         start_response('500 INTERNAL SERVER ERROR', [
             ('Content-Type', 'text/html')])
         yield _handle_off()
     finally:
         hasattr(appiter, 'close') and appiter.close()
     wdb.closed = False
예제 #12
0
파일: ext.py 프로젝트: minisin/wdb
 def trace_wsgi(environ, start_response):
     wdb = Wdb.get()
     wdb.closed = False
     appiter = None
     try:
         with trace(close_on_exit=True, under=self.app):
             appiter = self.app(environ, start_response)
             for item in appiter:
                 yield item
     except Exception:
         start_response('500 INTERNAL SERVER ERROR',
                        [('Content-Type', 'text/html')])
         yield _handle_off()
     finally:
         hasattr(appiter, 'close') and appiter.close()
     wdb.closed = False
예제 #13
0
파일: ext.py 프로젝트: niziou/wdb
 def catch(environ, start_response):
     wdb = Wdb.get()
     wdb.closed = False
     appiter = None
     try:
         appiter = self.app(environ, start_response)
         for item in appiter:
             yield item
     except Exception:
         start_response('500 INTERNAL SERVER ERROR', [
             ('Content-Type', 'text/html')])
         yield _handle_off()
     finally:
         # Close set_trace debuggers
         stop_trace(close_on_exit=True)
         hasattr(appiter, 'close') and appiter.close()
     wdb.closed = False
예제 #14
0
 def catch(environ, start_response):
     wdb = Wdb.get()
     wdb.closed = False
     appiter = None
     try:
         appiter = self.app(environ, start_response)
         for item in appiter:
             yield item
     except Exception:
         start_response('500 INTERNAL SERVER ERROR',
                        [('Content-Type', 'text/html')])
         yield _handle_off()
     finally:
         # Close set_trace debuggers
         stop_trace(close_on_exit=True)
         hasattr(appiter, 'close') and appiter.close()
     wdb.closed = False
예제 #15
0
파일: ext.py 프로젝트: niziou/wdb
    def _wdb_execute(*args, **kwargs):
        from wdb import trace, Wdb
        wdb = Wdb.get()
        wdb.closed = False  # Activate request ignores

        interesting = True
        if len(args) > 0 and isinstance(args[0], ErrorHandler):
            interesting = False
        elif len(args) > 2 and isinstance(
                args[0], StaticFileHandler) and args[2] == 'favicon.ico':
            interesting = False

        if Wdb.enabled and interesting:
            with trace(close_on_exit=True, under=under):
                old_execute(*args, **kwargs)
        else:
            old_execute(*args, **kwargs)
            # Close set_trace debuggers
            stop_trace(close_on_exit=True)

        # Reset closed state
        wdb.closed = False
예제 #16
0
파일: ext.py 프로젝트: minisin/wdb
def post_mortem_interaction(uuid, exc_info):
    wdb = Wdb.get(force_uuid=uuid)
    type_, value, tb = exc_info
    frame = None
    _value = value
    if not isinstance(_value, BaseException):
        _value = type_(value)

    wdb.obj_cache[id(exc_info)] = exc_info
    wdb.extra_vars['__exception__'] = exc_info
    exception = type_.__name__
    exception_description = str(value) + ' [POST MORTEM]'
    init = 'Echo|%s' % dump(
        {
            'for': '__exception__',
            'val': escape('%s: %s') % (exception, exception_description)
        })

    wdb.interaction(frame,
                    tb,
                    exception,
                    exception_description,
                    init=init,
                    iframe_mode=True)
예제 #17
0
파일: __init__.py 프로젝트: hekevintran/wdb
 def run():
     from wdb import Wdb
     Wdb.get().run_file(fn)
예제 #18
0
파일: __init__.py 프로젝트: TFenby/wdb
 def run():
     from wdb import Wdb
     Wdb.get().run_file(fn[0].decode('utf-8'))
예제 #19
0
 def run():
     from wdb import Wdb
     Wdb.get().shell()
예제 #20
0
 def wdb_pm(xtype, value, traceback):
     sys.__excepthook__(xtype, value, traceback)
     wdb = Wdb.get()
     wdb.reset()
     wdb.interaction(None, traceback, post_mortem=True)
예제 #21
0
파일: __main__.py 프로젝트: Kozea/wdb
 def wdb_pm(xtype, value, traceback):
     sys.__excepthook__(xtype, value, traceback)
     wdb = Wdb.get()
     wdb.reset()
     wdb.interaction(None, traceback, post_mortem=True)
예제 #22
0
 def run():
     from wdb import Wdb
     Wdb.get().run_file(fn)
예제 #23
0
 def run():
     from wdb import Wdb
     Wdb.get().shell()