blob: 8d46a5b55da74d11160b36dce92d86f982824377 [file] [log] [blame]
Mike Frysingerd03e6b52019-08-03 12:49:01 -04001#!/usr/bin/python2
mblighbe630eb2008-08-01 16:41:48 +00002"""
3Selects all rows and columns that satisfy the condition specified
4and prints the matrix.
5"""
6import sys, os, re, optparse
7import common
mbligh48d412c2009-07-02 18:55:35 +00008from autotest_lib.client.common_lib import kernel_versions
mblighbe630eb2008-08-01 16:41:48 +00009from autotest_lib.tko import display, frontend, db, query_lib
10
11# First do all the options parsing
12parser = optparse.OptionParser()
13parser.add_option('-x', '--x_axis', action='store', dest='x_axis',
14 default='machine_group')
15parser.add_option('-y', '--y_axis', action='store', dest='y_axis',
16 default='kernel')
17parser.add_option('-c', '--condition', action='store', dest='condition')
18(options, args) = parser.parse_args()
19
20if options.condition:
21 where = query_lib.parse_scrub_and_gen_condition(
22 options.condition, frontend.test_view_field_dict)
23 # print("where clause:" % where)
24else:
25 where = None
26
27# Grab the data
28db = db.db()
29test_data = frontend.get_matrix_data(db, options.x_axis, options.y_axis, where)
30
31# Print everything
32widest_row_header = max([len(y) for y in test_data.y_values])
33data_column_width = max([max(13,len(x)) for x in test_data.x_values])
34column_widths = [widest_row_header] + [data_column_width] * len(test_data.x_values)
35format = ' | '.join(['%%%ds' % i for i in column_widths])
36# Print headers
37print format % tuple([''] + test_data.x_values)
38
39# print data
40for y in test_data.y_values:
41 line = [y]
42 for x in test_data.x_values:
43 try:
44 data_point = test_data.data[x][y]
45 good_status = db.status_idx['GOOD']
46 good = data_point.status_count.get(good_status, 0)
47 total = sum(data_point.status_count.values())
48 line.append('%5d / %-5d' % (good, total))
49 except:
50 line.append('')
51 print format % tuple(line)