Ejemplo n.º 1
0
def pdb(element):
    if has_ipdb():
        from ipdb import set_trace
    else:
        from pdb import set_trace
    set_trace()
    return element
Ejemplo n.º 2
0
def ipdb(element):
    if has_ipdb():
        from ipdb import set_trace
    else:
        from django_pdb.utils import get_pdb_set_trace
        get_pdb_set_trace()()
    set_trace()
    return element
Ejemplo n.º 3
0
 def reraise(self, request, exc_type, exc_value, tb):
     if has_ipdb():
         import ipdb
         p = ipdb
     else:
         p = pdb
     if self.pm:
         print >>sys.stderr, "Exception occured: %s, %s" % (exc_type, exc_value)
         p.post_mortem(tb)
     else:
         raise
Ejemplo n.º 4
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        """
        If running with '--pdb', set a breakpoint at the start
        of each of each view before it gets called.
        """
        # Skip out unless using `runserver --pdb`,
        # or `pdb` is in the command line parameters
        type_pdb = self.get_type_pdb(request)
        if not type_pdb:
            return

        try:
            filename = inspect.getsourcefile(view_func)
        except TypeError:
            if hasattr(view_func, "__class__"):
                filename = inspect.getsourcefile(view_func.__class__)
                lines, lineno = inspect.getsourcelines(view_func.__class__)
            else:
                raise
        else:
            lines, lineno = inspect.getsourcelines(view_func)

        basename = os.path.basename(filename)
        dirname = os.path.basename(os.path.dirname(filename))
        temporary = True
        cond = None
        funcname = view_func.__name__

        print
        print '%s %s' % (request.method, request.get_full_path())
        print 'function "%s" in %s/%s:%d' % (funcname,
                                             dirname,
                                             basename,
                                             lineno)
        print 'args: %s' % (view_args,)
        print 'kwargs: %s' % (view_kwargs,)
        print

        if type_pdb == 'ipdb' and has_ipdb():
            p = get_ipdb()
        else:
            if not type_pdb == 'pdb':
                print 'You do not install ipdb or ipython module'
            p = pdb.Pdb()
        p.reset()
        p.set_break(filename, lineno + 1, temporary, cond, funcname)
        sys.settrace(p.trace_dispatch)
Ejemplo n.º 5
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        """
        If running with '--pdb', set a breakpoint at the start
        of each of each view before it gets called.
        """
        # Skip out unless using `runserver --pdb`,
        # or `pdb` is in the command line parameters
        type_pdb = self.get_type_pdb(request)
        if not type_pdb:
            return

        filename = inspect.getsourcefile(view_func)
        basename = os.path.basename(filename)
        dirname = os.path.basename(os.path.dirname(filename))
        lines, lineno = inspect.getsourcelines(view_func)
        temporary = True
        cond = None
        funcname = view_func.__name__

        print
        print '%s %s' % (request.method, request.get_full_path())
        print 'function "%s" in %s/%s:%d' % (funcname,
                                             dirname,
                                             basename,
                                             lineno)
        print 'args: %s' % (view_args,)
        print 'kwargs: %s' % (view_kwargs,)
        print

        if type_pdb == 'ipdb' and has_ipdb():
            p = get_ipdb()
        else:
            if not type_pdb == 'pdb':
                print 'You do not install ipdb or ipython module'
            p = pdb.Pdb()
        p.reset()
        p.set_break(filename, lineno + 1, temporary, cond, funcname)
        sys.settrace(p.trace_dispatch)
Ejemplo n.º 6
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        """
        If running with '--pdb', set a breakpoint at the start
        of each of each view before it gets called.
        """
        # Skip out unless using `runserver --pdb`,
        # or `pdb` is in the command line parameters
        type_pdb = self.get_type_pdb(request)
        if not type_pdb:
            return

        filename = inspect.getsourcefile(view_func)
        basename = os.path.basename(filename)
        dirname = os.path.basename(os.path.dirname(filename))
        lines, lineno = inspect.getsourcelines(view_func)
        temporary = True
        cond = None
        funcname = view_func.__name__

        print()
        print('{} {}'.format(request.method, request.get_full_path()))
        print('function "{}" in {}/{}:{}'.format(funcname,
            dirname, basename, lineno))
        print('args: {}'.format(view_args))
        print('kwargs: {}'.format(view_kwargs))
        print()

        if type_pdb == 'ipdb' and has_ipdb():
            p = get_ipdb()
        else:
            if not type_pdb == 'pdb':
                print('You do not install ipdb or ipython module')
            p = pdb.Pdb()
        p.reset()
        p.set_break(filename, lineno + 1, temporary, cond, funcname)
        sys.settrace(p.trace_dispatch)
Ejemplo n.º 7
0
 def get_pdb(self):
     if self.pdb_type == 'ipdb' and has_ipdb():
         import ipdb
         return ipdb
     return pdb