common_lib.base_packages: Add parallel bzip2 support to package manager
[autotest-zwu.git] / tko / test.cgi
blob4b4f66880da7f4ad4a4fe2d1301782596ba5299b
1 #!/usr/bin/python
2 """
3 Further display the tests in a matrix of the form tests X machines
4 to help understand the results selected from the previous form.
5 """
7 print "Content-type: text/html\n"
8 import cgi, cgitb, os, sys, re
9 sys.stdout.flush()
10 cgitb.enable()
12 import common
13 from autotest_lib.tko import db, display, frontend
15 db = db.db()
17 def main():
18 display.print_main_header()
20 form = cgi.FieldStorage()
22 if form.has_key('sql'):
23 sql = form['sql'].value
25 if form.has_key('values'):
26 values = [val for val in form['values'].value.split(',')]
28 if not sql:
29 return
30 if not values:
31 return
33 tests = frontend.test.select_sql(db, sql, values)
35 # get the list of tests/machines to populate the row and column header.
36 testname = [test.testname for test in tests]
37 machine_idx = [test.machine_idx for test in tests]
39 # We dont want repetitions in the table row/column headers,
40 # so eliminate the dups.
41 uniq_test = list(set(testname))
42 uniq_machine_idx = list(set(machine_idx))
44 header_row = [ display.box('', header = True) ]
45 for test_name in uniq_test:
46 header_row.append(display.box(test_name, header=True))
47 matrix = [header_row]
48 for machine in uniq_machine_idx:
49 mach_name = db.select_sql('hostname', 'machines',
50 ' where machine_idx=%s', [str(machine)])
51 row = [display.box(mach_name[0][0])]
52 for test_name in uniq_test:
53 testlist = [test for test in tests
54 if test.machine_idx == machine
55 and test.testname == test_name]
56 # url link to the first test.
57 # TODO: provide another level to show the different
58 # test results.
59 link = None
60 if testlist and testlist[0]:
61 link = testlist[0].url
62 box = display.status_count_box(db, testlist, link=link)
63 row.append(box)
64 matrix.append(row)
65 display.print_table(matrix)
67 main()