Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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())
Esempio n. 4
0
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())