mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | """ |
| 3 | Selects all rows and columns that satisfy the condition specified |
| 4 | and prints the matrix. |
| 5 | """ |
| 6 | import sys, os, re, optparse |
| 7 | import common |
mbligh | 48d412c | 2009-07-02 18:55:35 +0000 | [diff] [blame^] | 8 | from autotest_lib.client.common_lib import kernel_versions |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 9 | from autotest_lib.tko import display, frontend, db, query_lib |
| 10 | |
| 11 | # First do all the options parsing |
| 12 | parser = optparse.OptionParser() |
| 13 | parser.add_option('-x', '--x_axis', action='store', dest='x_axis', |
| 14 | default='machine_group') |
| 15 | parser.add_option('-y', '--y_axis', action='store', dest='y_axis', |
| 16 | default='kernel') |
| 17 | parser.add_option('-c', '--condition', action='store', dest='condition') |
| 18 | (options, args) = parser.parse_args() |
| 19 | |
| 20 | if options.condition: |
| 21 | where = query_lib.parse_scrub_and_gen_condition( |
| 22 | options.condition, frontend.test_view_field_dict) |
| 23 | # print("where clause:" % where) |
| 24 | else: |
| 25 | where = None |
| 26 | |
| 27 | # Grab the data |
| 28 | db = db.db() |
| 29 | test_data = frontend.get_matrix_data(db, options.x_axis, options.y_axis, where) |
| 30 | |
| 31 | # Print everything |
| 32 | widest_row_header = max([len(y) for y in test_data.y_values]) |
| 33 | data_column_width = max([max(13,len(x)) for x in test_data.x_values]) |
| 34 | column_widths = [widest_row_header] + [data_column_width] * len(test_data.x_values) |
| 35 | format = ' | '.join(['%%%ds' % i for i in column_widths]) |
| 36 | # Print headers |
| 37 | print format % tuple([''] + test_data.x_values) |
| 38 | |
| 39 | # print data |
| 40 | for 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) |