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 """ 6 7 print "Content-type: text/html\n" 8 import cgi, cgitb, os, sys, re 9 sys.stdout.flush() 10 cgitb.enable() 11 12 import common 13 from autotest_lib.tko import db, display, frontend 14 15 db = db.db() 16 17 def main(): 18 display.print_main_header() 19 20 form = cgi.FieldStorage() 21 22 if form.has_key('sql'): 23 sql = form['sql'].value 24 25 if form.has_key('values'): 26 values = [val for val in form['values'].value.split(',')] 27 28 if not sql: 29 return 30 if not values: 31 return 32 33 tests = frontend.test.select_sql(db, sql, values) 34 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] 38 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)) 43 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) 66 67 main() 68