blob: d96d82f5d551606dd2c1a843713c0b5ed6f83110 [file] [log] [blame]
mbligh2e4e5df2007-11-05 17:22:46 +00001#!/usr/bin/python
2"""
3Further display the tests in a matrix of the form tests X machines
4to help understand the results selected from the previous form.
5"""
6
7print "Content-type: text/html\n"
8import cgi, cgitb, os, sys, re
9sys.stdout.flush()
10cgitb.enable()
11
12tko = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))
13sys.path.insert(0, tko)
14import db, display, frontend
15
16db = db.db()
17
18def main():
mbligh1405f4e2007-11-05 19:26:23 +000019 display.print_main_header()
20
mbligh2e4e5df2007-11-05 17:22:46 +000021 form = cgi.FieldStorage()
22
23 if form.has_key('sql'):
24 sql = form['sql'].value
25
26 if form.has_key('values'):
27 values = [val for val in form['values'].value.split(',')]
28
29 if not sql:
30 return
31 if not values:
32 return
33
34 tests = frontend.test.select_sql(db, sql, values)
35
36 # get the list of tests/machines to populate the row and column header.
37 testname = [test.testname for test in tests]
38 machine_idx = [test.machine_idx for test in tests]
39
40 # We dont want repetitions in the table row/column headers,
41 # so eliminate the dups.
42 uniq_test = list(set(testname))
43 uniq_machine_idx = list(set(machine_idx))
44
45 header_row = [ display.box('', header = True) ]
46 for test_name in uniq_test:
47 header_row.append(display.box(test_name, header=True))
48 matrix = [header_row]
49 for machine in uniq_machine_idx:
50 mach_name = db.select_sql('hostname', 'machines',
51 ' where machine_idx=%s', [str(machine)])
52 row = [display.box(mach_name[0][0])]
53 for test_name in uniq_test:
54 testlist = [test for test in tests
55 if test.machine_idx == machine
56 and test.testname == test_name]
57 # url link to the first test.
58 # TODO: provide another level to show the different
59 # test results.
60 link = None
61 if testlist and testlist[0]:
62 link = testlist[0].url
63 box = display.status_count_box(db, testlist, link=link)
64 row.append(box)
65 matrix.append(row)
66 display.print_table(matrix)
67
68main()