コード例 #1
0
ファイル: pcgi_detail.py プロジェクト: eslavich/pandokia
def next_prev(d_in, test_run):
    tmp = ''
    tmp1 = common.run_previous(None, test_run)
    if tmp1 is not None:
        d_in["test_run"] = tmp1
        tmp = tmp + " &nbsp;&nbsp;(<a href=%s>%s</a>)" % (common.selflink(
            d_in, linkmode='detail'), tmp1)
    tmp2 = common.run_next(None, test_run)
    if tmp2 is not None:
        d_in["test_run"] = tmp2
        tmp = tmp + " &nbsp;&nbsp;(<a href=%s>%s</a>)" % (common.selflink(
            d_in, linkmode='detail'), tmp2)
    return tmp
コード例 #2
0
ファイル: pcgi_detail.py プロジェクト: jhunkeler/pandokia
def next_prev(d_in, test_run):
    tmp = ''
    tmp1 = common.run_previous(None, test_run)
    if tmp1 is not None:
        d_in["test_run"] = tmp1
        tmp = tmp + " &nbsp;&nbsp;(<a href=%s>%s</a>)" % (
            common.selflink(d_in, linkmode='detail'), tmp1)
    tmp2 = common.run_next(None, test_run)
    if tmp2 is not None:
        d_in["test_run"] = tmp2
        tmp = tmp + " &nbsp;&nbsp;(<a href=%s>%s</a>)" % (
            common.selflink(d_in, linkmode='detail'), tmp2)
    return tmp
コード例 #3
0
ファイル: pcgi_day_report.py プロジェクト: mcara/pandokia
def rpt2():

    form = pandokia.pcgi.form

    if form.has_key("test_run"):
        test_run = form["test_run"].value
    else:
        # no parameter?  I think somebody is messing with us...
        # no matter - just give them a the list of all the test_runs
        rpt1()
        return

    #
    test_run = common.find_test_run(test_run)

    # create list of projects
    projects = None
    host = None
    context = None
    chronic = '0'

    if form.has_key("project"):
        projects = form.getlist("project")

    if form.has_key("host"):
        host = form.getlist("host")

    if form.has_key("context"):
        context = form.getlist("context")

    if form.has_key("chronic"):
        chronic = form.getlist("chronic")[0]

    c = pdk_db.execute(
        "SELECT note, valuable FROM distinct_test_run WHERE test_run = :1",
        (test_run, ))
    x = c.fetchone()
    if x is None:
        sys.stdout.write(common.cgi_header_html)
        sys.stdout.write(common.page_header())
        sys.stdout.write('No such test run')
        return

    test_run_note, test_run_valuable = x
    if test_run_note is None:
        test_run_note = ''
    if test_run_valuable is None:
        test_run_valuable = 0
    else:
        test_run_valuable = int(test_run_valuable)

    # create the actual table
    (table, projects) = gen_daily_table(test_run,
                                        projects,
                                        context,
                                        host,
                                        valuable=test_run_valuable,
                                        chronic=chronic == '1')

    # # # # # # # # # #
    if pandokia.pcgi.output_format == 'html':

        header = "<big><big><b>" + cgi.escape(test_run) + "</b></big></big>\n"

        if 1:
            # if it looks like there is a date in it, try to show the day of the week
            # dates must look like 2011-01-01 and do not occur at the beginning of the name
            t = common.looks_like_a_date(test_run)
            try:
                import datetime
                t = t.group(1).split('-')
                (year, month, day) = (int(t[0]), int(t[1]), int(t[2]))
                t = datetime.date(year, month, day)
                t = t.strftime("%A")
                header = header + "<big>(" + str(t) + ")</big>"
            except:
                pass

        header = header + "<p>"

        recurring_prefix = common.recurring_test_run(test_run)
        if recurring_prefix:
            #
            # If we have a recurring run, create a special header.

            # Include links to the previous / next in the sequence

            l = []
            prev = common.run_previous(recurring_prefix, test_run)
            if prev:
                l.append(
                    common.self_href(query_dict={'test_run': prev},
                                     linkmode='day_report.2',
                                     text=prev))

            next = common.run_next(recurring_prefix, test_run)
            if next:
                l.append(
                    common.self_href(query_dict={'test_run': next},
                                     linkmode='day_report.2',
                                     text=next))

            latest = common.run_latest(recurring_prefix)
            if latest and (latest != next) and (latest != test_run):
                l.append(
                    common.self_href(query_dict={'test_run': latest},
                                     linkmode='day_report.2',
                                     text=latest))

            header = header + '( %s )' % (' / '.join(l))

        if 1:
            if test_run_note.startswith('*'):
                header = header + '<p>\nNote: %s</p>' % (
                    cgi.escape(test_run_note))
            else:
                header = header + '<p><form action=%s>\nNote: <input type=text name=note value="%s" size=%d>\n<input type=hidden name=test_run value="%s">\n<input type=hidden name=query value=action></form></p>' % (
                    common.get_cgi_name(), cgi.escape(test_run_note),
                    len(test_run_note) + 20, test_run)

            if test_run_valuable:
                header = header + '<p>valuable '
            else:
                header = header + '<p>not valuable '
            header = header + '(<a href=%s>change</a>)' % (common.selflink(
                {
                    'test_run': test_run,
                    'valuable_run': int(not test_run_valuable)
                },
                linkmode='action'))

        sys.stdout.write(common.cgi_header_html)
        sys.stdout.write(common.page_header())
        sys.stdout.write(header)

        # write links to the top of each project
        sys.stdout.write('<p>\n')
        for p in projects:
            p = cgi.escape(p)
            sys.stdout.write('<a href="#%s">%s</a>&nbsp;&nbsp; ' % (p, p))
        sys.stdout.write('</p>\n')

        # write the report table
        sys.stdout.write(table.get_html(headings=0))

    elif pandokia.pcgi.output_format == 'csv':
        sys.stdout.write(common.cgi_header_csv)
        sys.stdout.write(table.get_csv())
コード例 #4
0
ファイル: pcgi_detail.py プロジェクト: eslavich/pandokia
def run():

    sys.stdout.write(common.cgi_header_html)
    sys.stdout.write(common.page_header())

    form = pandokia.pcgi.form

    if "test_name" in form:
        test_name = form.getvalue("test_name")
    else:
        test_name = ""

    if "context" in form:
        context = form.getvalue("context")
    else:
        context = "*"

    if "custom" in form:
        custom = form.getvalue("custom")
    else:
        custom = "*"

    if "host" in form:
        host = form.getvalue("host")
    else:
        host = "*"

    if "test_run" in form:
        test_run = form.getvalue("test_run")
    else:
        test_run = "*"

    if "project" in form:
        project = form.getvalue("project")
    else:
        project = "*"

    if "status" in form:
        status = form.getvalue("status")
    else:
        status = "*"

    if "test_name" in form:
        cmp_run = form.getvalue("test_name")
        if cmp_run == '':
            cmp_run = common.run_previous(None, test_run)
            if cmp_run is not None:
                cmp_run = common.find_test_run(cmp_run)
            else:
                cmp_run = ''
        else:
            cmp_run = common.find_test_run(cmp_run)
    else:
        cmp_run = ""

    if "key_id" in form:
        key_id = form.getvalue("key_id")
    else:
        key_id = ""

    if "qid" in form:
        qid = form.getvalue("qid")
    else:
        qid = ""

    #
    # main heading
    #

    sys.stdout.write("<h1>Test detail</h1>\n")

    #
    # this query finds all the test results that are an interesting part of this request
    #

    if key_id != "":
        n = do_result(key_id)
    elif qid != "":
        c1 = pdk_db.execute("SELECT key_id FROM query WHERE qid = :1 ",
                            (qid, ))
        l = []
        for x in c1:
            l.append(x[0])
        del c1
        n = 0
        for key_id in l:
            n = n + do_result(key_id)
    else:
        c1 = pdk_db.execute(
            "SELECT key_id FROM result_scalar WHERE test_run = :1 AND project = :2 AND host = :3 AND test_name = :4 AND context = :5 AND custom = :6 ",
            (test_run, project, host, test_name, context, custom))
        n = 0
        for x in c1:
            (key_id, ) = x
            n = n + do_result(key_id)

    if n == 0:
        sys.stdout.write("no tests match\n")
        d_in = {
            'project': project,
            'host': host,
            'context': context,
            'custom': custom,
            'test_run': test_run,
            'test_name': test_name
        }
        t = next_prev(d_in, test_run)
        if t != '':
            sys.stdout.write(t)
コード例 #5
0
ファイル: pcgi_detail.py プロジェクト: jhunkeler/pandokia
def run():

    sys.stdout.write(common.cgi_header_html)
    sys.stdout.write(common.page_header())

    form = pandokia.pcgi.form

    if "test_name" in form:
        test_name = form.getvalue("test_name")
    else:
        test_name = ""

    if "context" in form:
        context = form.getvalue("context")
    else:
        context = "*"

    if "host" in form:
        host = form.getvalue("host")
    else:
        host = "*"

    if "test_run" in form:
        test_run = form.getvalue("test_run")
    else:
        test_run = "*"

    if "project" in form:
        project = form.getvalue("project")
    else:
        project = "*"

    if "status" in form:
        status = form.getvalue("status")
    else:
        status = "*"

    if "test_name" in form:
        cmp_run = form.getvalue("test_name")
        if cmp_run == '':
            cmp_run = common.run_previous(None, test_run)
            if cmp_run is not None:
                cmp_run = common.find_test_run(cmp_run)
            else:
                cmp_run = ''
        else:
            cmp_run = common.find_test_run(cmp_run)
    else:
        cmp_run = ""

    if "key_id" in form:
        key_id = form.getvalue("key_id")
    else:
        key_id = ""

    if "qid" in form:
        qid = form.getvalue("qid")
    else:
        qid = ""

    #
    # main heading
    #

    sys.stdout.write("<h1>Test detail</h1>\n")

    #
    # this query finds all the test results that are an interesting part of this request
    #

    if key_id != "":
        n = do_result(key_id)
    elif qid != "":
        c1 = pdk_db.execute("SELECT key_id FROM query WHERE qid = :1 ", (qid,))
        l = []
        for x in c1:
            l.append(x[0])
        del c1
        n = 0
        for key_id in l:
            n = n + do_result(key_id)
    else:
        c1 = pdk_db.execute(
            "SELECT key_id FROM result_scalar WHERE test_run = :1 AND project = :2 AND host = :3 AND test_name = :4 AND context = :5 ",
            (test_run,
             project,
             host,
             test_name,
             context))
        n = 0
        for x in c1:
            (key_id, ) = x
            n = n + do_result(key_id)

    if n == 0:
        sys.stdout.write("no tests match\n")
        d_in = {
            'project': project,
            'host': host,
            'context': context,
            'test_run': test_run,
            'test_name': test_name}
        t = next_prev(d_in, test_run)
        if t != '':
            sys.stdout.write(t)
コード例 #6
0
ファイル: pcgi_day_report.py プロジェクト: jhunkeler/pandokia
def rpt2():

    form = pandokia.pcgi.form

    if "test_run" in form:
        test_run = form.getvalue("test_run")
    else:
        # no parameter?  I think somebody is messing with us...
        # no matter - just give them a the list of all the test_runs
        rpt1()
        return

    #
    test_run = common.find_test_run(test_run)

    # create list of projects
    projects = None
    host = None
    context = None
    chronic = '0'

    if "project" in form:
        projects = form.getlist("project")

    if "host" in form:
        host = form.getlist("host")

    if "context" in form:
        context = form.getlist("context")

    if "chronic" in form:
        chronic = form.getlist("chronic")[0]

    c = pdk_db.execute(
        "SELECT note, valuable FROM distinct_test_run WHERE test_run = :1", (test_run,))
    x = c.fetchone()
    if x is None:
        sys.stdout.write(common.cgi_header_html)
        sys.stdout.write(common.page_header())
        sys.stdout.write('No such test run')
        return

    test_run_note, test_run_valuable = x
    if test_run_note is None:
        test_run_note = ''
    if test_run_valuable is None:
        test_run_valuable = 0
    else:
        test_run_valuable = int(test_run_valuable)

    # create the actual table
    (table, projects) = gen_daily_table(test_run, projects, context,
                                        host, valuable=test_run_valuable, chronic=chronic == '1')

# # # # # # # # # #
    if pandokia.pcgi.output_format == 'html':

        header = "<big><big><b>" + cgi.escape(test_run) + "</b></big></big>\n"

        if 1:
            # if it looks like there is a date in it, try to show the day of the week
            # dates must look like 2011-01-01 and do not occur at the beginning
            # of the name
            t = common.looks_like_a_date(test_run)
            try:
                import datetime
                t = t.group(1).split('-')
                (year, month, day) = (int(t[0]), int(t[1]), int(t[2]))
                t = datetime.date(year, month, day)
                t = t.strftime("%A")
                header = header + "<big>(" + str(t) + ")</big>"
            except:
                pass

        header = header + "<p>"

        recurring_prefix = common.recurring_test_run(test_run)
        if recurring_prefix:
            #
            # If we have a recurring run, create a special header.

            # Include links to the previous / next in the sequence

            l = []
            prev = common.run_previous(recurring_prefix, test_run)
            if prev:
                l.append(
                    common.self_href(
                        query_dict={
                            'test_run': prev},
                        linkmode='day_report.2',
                        text=prev))

            next = common.run_next(recurring_prefix, test_run)
            if next:
                l.append(
                    common.self_href(
                        query_dict={
                            'test_run': next},
                        linkmode='day_report.2',
                        text=next))

            latest = common.run_latest(recurring_prefix)
            if latest and (latest != next) and (latest != test_run):
                l.append(
                    common.self_href(
                        query_dict={
                            'test_run': latest},
                        linkmode='day_report.2',
                        text=latest))

            header = header + '( %s )' % (' / '.join(l))

        if 1:
            if test_run_note.startswith('*'):
                header = header + \
                    '<p>\nNote: %s</p>' % (cgi.escape(test_run_note))
            else:
                header = header + '<p><form action=%s>\nNote: <input type=text name=note value="%s" size=%d>\n<input type=hidden name=test_run value="%s">\n<input type=hidden name=query value=action></form></p>' % (
                    common.get_cgi_name(), cgi.escape(test_run_note), len(test_run_note) + 20, test_run)

            if test_run_valuable:
                header = header + '<p>valuable '
            else:
                header = header + '<p>not valuable '
            header = header + '(<a href=%s>change</a>)' % (common.selflink(
                {'test_run': test_run, 'valuable_run': int(not test_run_valuable)}, linkmode='action'))

        sys.stdout.write(common.cgi_header_html)
        sys.stdout.write(common.page_header())
        sys.stdout.write(header)

        # write links to the top of each project
        sys.stdout.write('<p>\n')
        for p in projects:
            p = cgi.escape(p)
            sys.stdout.write('<a href="#%s">%s</a>&nbsp;&nbsp; ' % (p, p))
        sys.stdout.write('</p>\n')

        # write the report table
        sys.stdout.write(table.get_html(headings=0))

    elif pandokia.pcgi.output_format == 'csv':
        sys.stdout.write(common.cgi_header_csv)
        sys.stdout.write(table.get_csv())