コード例 #1
0
ファイル: debug.py プロジェクト: oddquist/web2py
def toggle_breakpoint():
    "Set or clear a breakpoint"
    
    lineno = None
    ok = None
    try:
        filename = os.path.join(request.env['applications_parent'], 
                                'applications', request.vars.filename)
        start = 0
        sel_start = int(request.vars.sel_start)
        for lineno, line in enumerate(request.vars.data.split("\n")):
            if sel_start <= start:
                break
            start += len(line) + 1
        else:
            lineno = None
        if lineno is not None:
            for bp in qdb_debugger.do_list_breakpoint():
                no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp
                if filename == bp_filename and lineno == bp_lineno:
                    err = qdb_debugger.do_clear_breakpoint(filename, lineno)
                    response.flash = T("Removed Breakpoint on %s at line %s", ( 
                                        filename, lineno))
                    ok = False
                    break
            else:
                err = qdb_debugger.do_set_breakpoint(filename, lineno)
                response.flash = T("Set Breakpoint on %s at line %s: %s") % (
                                    filename, lineno, err or T('successful'))
                ok = True
        else:
            response.flash = T("Unable to determine the line number!")
    except Exception, e:
        session.flash = str(e)
コード例 #2
0
ファイル: debug.py プロジェクト: Anupriya-Inumella/CourseWork
def toggle_breakpoint():
    "Set or clear a breakpoint"

    lineno = None
    ok = None
    try:
        filename = os.path.join(request.env['applications_parent'],
                                'applications', request.vars.filename)
        start = 0
        sel_start = int(request.vars.sel_start)
        for lineno, line in enumerate(request.vars.data.split("\n")):
            if sel_start <= start:
                break
            start += len(line) + 1
        else:
            lineno = None
        if lineno is not None:
            for bp in qdb_debugger.do_list_breakpoint():
                no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp
                if filename == bp_filename and lineno == bp_lineno:
                    err = qdb_debugger.do_clear_breakpoint(filename, lineno)
                    response.flash = T("Removed Breakpoint on %s at line %s",
                                       (filename, lineno))
                    ok = False
                    break
            else:
                err = qdb_debugger.do_set_breakpoint(filename, lineno)
                response.flash = T("Set Breakpoint on %s at line %s: %s") % (
                    filename, lineno, err or T('successful'))
                ok = True
        else:
            response.flash = T("Unable to determine the line number!")
    except Exception, e:
        session.flash = str(e)
コード例 #3
0
ファイル: debug.py プロジェクト: JakrarinSrimakut/Android
def breakpoints():
    "Add or remove breakpoints"

    # Get all .py files
    files = listdir(apath('', r=request), '.*\.py$')
    files = [
        filename for filename in files
        if filename and 'languages' not in filename and not filename.
        startswith("admin") and not filename.startswith("examples")
    ]

    form = SQLFORM.factory(
        Field('filename', requires=IS_IN_SET(files), label=T("Filename")),
        Field('lineno',
              'integer',
              label=T("Line number"),
              requires=IS_NOT_EMPTY()),
        Field('temporary',
              'boolean',
              label=T("Temporary"),
              comment=T("deleted after first hit")),
        Field('condition',
              'string',
              label=T("Condition"),
              comment=T("honored only if the expression evaluates to true")),
    )

    if form.accepts(request.vars, session):
        filename = os.path.join(request.env['applications_parent'],
                                'applications', form.vars.filename)
        err = qdb_debugger.do_set_breakpoint(filename, form.vars.lineno,
                                             form.vars.temporary,
                                             form.vars.condition)
        response.flash = T("Set Breakpoint on %s at line %s: %s") % (
            filename, form.vars.lineno, err or T('successful'))

    for item in request.vars:
        if item[:7] == 'delete_':
            qdb_debugger.do_clear(item[7:])

    breakpoints = [{
        'number': bp[0],
        'filename': os.path.basename(bp[1]),
        'path': bp[1],
        'lineno': bp[2],
        'temporary': bp[3],
        'enabled': bp[4],
        'hits': bp[5],
        'condition': bp[6]
    } for bp in qdb_debugger.do_list_breakpoint()]

    return dict(breakpoints=breakpoints, form=form)
コード例 #4
0
def breakpoints():
    "Add or remove breakpoints"

    # Get all .py files
    files = listdir(apath("", r=request), ".*\.py$")
    files = [
        filename
        for filename in files
        if filename
        and "languages" not in filename
        and not filename.startswith("admin")
        and not filename.startswith("examples")
    ]

    form = SQLFORM.factory(
        Field("filename", requires=IS_IN_SET(files), label=T("Filename")),
        Field("lineno", "integer", label=T("Line number"), requires=IS_NOT_EMPTY()),
        Field("temporary", "boolean", label=T("Temporary"), comment=T("deleted after first hit")),
        Field(
            "condition", "string", label=T("Condition"), comment=T("honored only if the expression evaluates to true")
        ),
    )

    if form.accepts(request.vars, session):
        filename = os.path.join(request.env["applications_parent"], "applications", form.vars.filename)
        err = qdb_debugger.do_set_breakpoint(filename, form.vars.lineno, form.vars.temporary, form.vars.condition)
        response.flash = T("Set Breakpoint on %s at line %s: %s") % (filename, form.vars.lineno, err or T("successful"))

    for item in request.vars:
        if item[:7] == "delete_":
            qdb_debugger.do_clear(item[7:])

    breakpoints = [
        {
            "number": bp[0],
            "filename": os.path.basename(bp[1]),
            "path": bp[1],
            "lineno": bp[2],
            "temporary": bp[3],
            "enabled": bp[4],
            "hits": bp[5],
            "condition": bp[6],
        }
        for bp in qdb_debugger.do_list_breakpoint()
    ]

    return dict(breakpoints=breakpoints, form=form)
コード例 #5
0
ファイル: debug.py プロジェクト: ngorham/project_bacon
def list_breakpoints():
    "Return a list of linenumbers for current breakpoints"

    breakpoints = []
    ok = False
    try:
        filename = os.path.join(request.env["applications_parent"], "applications", request.vars.filename)
        # normalize path name: replace slashes, references, etc...
        filename = os.path.normpath(os.path.normcase(filename))
        for bp in qdb_debugger.do_list_breakpoint():
            no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp
            # normalize path name: replace slashes, references, etc...
            bp_filename = os.path.normpath(os.path.normcase(bp_filename))
            if filename == bp_filename:
                breakpoints.append(bp_lineno)
        ok = True
    except Exception, e:
        session.flash = str(e)
コード例 #6
0
ファイル: debug.py プロジェクト: JackRoderick/web2py
def toggle_breakpoint():
    "Set or clear a breakpoint"

    lineno = None
    ok = None
    try:
        filename = os.path.join(request.env['applications_parent'],
                                'applications', request.vars.filename)
        # normalize path name: replace slashes, references, etc...
        filename = os.path.normpath(os.path.normcase(filename))
        if not request.vars.data:
            # ace send us the line number!
            lineno = int(request.vars.sel_start) + 1
        else:
            # editarea send us the offset, manually check the cursor pos
            start = 0
            sel_start = int(request.vars.sel_start)
            for lineno, line in enumerate(request.vars.data.split("\n")):
                if sel_start <= start:
                    break
                start += len(line) + 1
            else:
                lineno = None
        if lineno is not None:
            for bp in qdb_debugger.do_list_breakpoint():
                no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp
                # normalize path name: replace slashes, references, etc...
                bp_filename = os.path.normpath(os.path.normcase(bp_filename))
                if filename == bp_filename and lineno == bp_lineno:
                    err = qdb_debugger.do_clear_breakpoint(filename, lineno)
                    response.flash = T("Removed Breakpoint on %s at line %s", (
                        filename, lineno))
                    ok = False
                    break
            else:
                err = qdb_debugger.do_set_breakpoint(filename, lineno)
                response.flash = T("Set Breakpoint on %s at line %s: %s") % (
                    filename, lineno, err or T('successful'))
                ok = True
        else:
            response.flash = T("Unable to determine the line number!")
    except Exception as e:
        session.flash = str(e)
    return response.json({'ok': ok, 'lineno': lineno})
コード例 #7
0
ファイル: debug.py プロジェクト: pranjalpatil/web2py
def toggle_breakpoint():
    "Set or clear a breakpoint"

    lineno = None
    ok = None
    try:
        filename = os.path.join(request.env['applications_parent'],
                                'applications', request.vars.filename)
        # normalize path name: replace slashes, references, etc...
        filename = os.path.normpath(os.path.normcase(filename))
        if not request.vars.data:
            # ace send us the line number!
            lineno = int(request.vars.sel_start) + 1
        else:
            # editarea send us the offset, manually check the cursor pos
            start = 0
            sel_start = int(request.vars.sel_start)
            for lineno, line in enumerate(request.vars.data.split("\n")):
                if sel_start <= start:
                    break
                start += len(line) + 1
            else:
                lineno = None
        if lineno is not None:
            for bp in qdb_debugger.do_list_breakpoint():
                no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp
                # normalize path name: replace slashes, references, etc...
                bp_filename = os.path.normpath(os.path.normcase(bp_filename))
                if filename == bp_filename and lineno == bp_lineno:
                    err = qdb_debugger.do_clear_breakpoint(filename, lineno)
                    response.flash = T("Removed Breakpoint on %s at line %s",
                                       (filename, lineno))
                    ok = False
                    break
            else:
                err = qdb_debugger.do_set_breakpoint(filename, lineno)
                response.flash = T("Set Breakpoint on %s at line %s: %s") % (
                    filename, lineno, err or T('successful'))
                ok = True
        else:
            response.flash = T("Unable to determine the line number!")
    except Exception as e:
        session.flash = str(e)
    return response.json({'ok': ok, 'lineno': lineno})
コード例 #8
0
ファイル: debug.py プロジェクト: JakrarinSrimakut/Android
def list_breakpoints():
    "Return a list of linenumbers for current breakpoints"

    breakpoints = []
    ok = False
    try:
        filename = os.path.join(request.env['applications_parent'],
                                'applications', request.vars.filename)
        # normalize path name: replace slashes, references, etc...
        filename = os.path.normpath(os.path.normcase(filename))
        for bp in qdb_debugger.do_list_breakpoint():
            no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp
            # normalize path name: replace slashes, references, etc...
            bp_filename = os.path.normpath(os.path.normcase(bp_filename))
            if filename == bp_filename:
                breakpoints.append(bp_lineno)
        ok = True
    except Exception, e:
        session.flash = str(e)
コード例 #9
0
ファイル: debug.py プロジェクト: AlecTaylor/openshift_web2py
def breakpoints():
    "Add or remove breakpoints"

    # Get all .py files
    files = listdir(apath('', r=request), '.*\.py$')
    files = [filename for filename in files
             if filename and 'languages' not in filename
             and not filename.startswith("admin")
             and not filename.startswith("examples")]

    form = SQLFORM.factory(
        Field('filename', requires=IS_IN_SET(files), label=T("Filename")),
        Field('lineno', 'integer', label=T("Line number"),
              requires=IS_NOT_EMPTY()),
        Field('temporary', 'boolean', label=T("Temporary"),
              comment=T("deleted after first hit")),
        Field('condition', 'string', label=T("Condition"),
              comment=T("honored only if the expression evaluates to true")),
    )

    if form.accepts(request.vars, session):
        filename = os.path.join(request.env['applications_parent'],
                                'applications', form.vars.filename)
        err = qdb_debugger.do_set_breakpoint(filename,
                                             form.vars.lineno,
                                             form.vars.temporary,
                                             form.vars.condition)
        response.flash = T("Set Breakpoint on %s at line %s: %s") % (
            filename, form.vars.lineno, err or T('successful'))

    for item in request.vars:
        if item[:7] == 'delete_':
            qdb_debugger.do_clear(item[7:])

    breakpoints = [{'number': bp[0], 'filename': os.path.basename(bp[1]),
                    'path': bp[1], 'lineno': bp[2],
                    'temporary': bp[3], 'enabled': bp[4], 'hits': bp[5],
                    'condition': bp[6]}
                   for bp in qdb_debugger.do_list_breakpoint()]

    return dict(breakpoints=breakpoints, form=form)