Print results clearly even if test names are very long. Also, for consistency, use the same quote character everywhere. Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> --- client/tests/kvm/scan_results.py | 49 ++++++++++++++++++++++--------------- 1 files changed, 29 insertions(+), 20 deletions(-) diff --git a/client/tests/kvm/scan_results.py b/client/tests/kvm/scan_results.py index f7bafa9..f7073e4 100755 --- a/client/tests/kvm/scan_results.py +++ b/client/tests/kvm/scan_results.py @@ -24,19 +24,19 @@ def parse_results(text): # Found a START line -- get start time if (line.startswith("START") and len(parts) >= 5 and parts[3].startswith("timestamp")): - start_time = float(parts[3].split('=')[1]) + start_time = float(parts[3].split("=")[1]) start_time_list.append(start_time) info_list.append("") # Found an END line -- get end time, name and status elif (line.startswith("END") and len(parts) >= 5 and parts[3].startswith("timestamp")): - end_time = float(parts[3].split('=')[1]) + end_time = float(parts[3].split("=")[1]) start_time = start_time_list.pop() info = info_list.pop() test_name = parts[2] test_status = parts[0].split()[1] - # Remove 'kvm.' prefix + # Remove "kvm." prefix if test_name.startswith("kvm."): test_name = test_name.split("kvm.")[1] result_list.append((test_name, test_status, @@ -50,39 +50,48 @@ def parse_results(text): return result_list -def print_result(result): - """Nicely print a single Autotest result. +def print_result(result, name_width): + """ + Nicely print a single Autotest result. - result -- a 4-tuple + @param result: a 4-tuple + @param name_width: test name maximum width """ if result: - print '%-48s\t\t%s\t%s\t%s' % tuple(map(str, result)) + format = "%%-%ds %%-10s %%-8s %%s" % name_width + print format % result def main(resfiles): - print_result(('Test', 'Status', 'Seconds', 'Info')) - print_result(('----', '------', '-------', '----')) + result_lists = [] + name_width = 40 for resfile in resfiles: - print ' (Result file: %s)' % resfile try: - f = file(resfile) - text = f.read() - f.close() + text = open(resfile).read() except IOError: - print 'Bad result file: %s' % resfile - return + print "Bad result file: %s" % resfile + continue results = parse_results(text) - map(print_result, results) + result_lists.append((resfile, results)) + name_width = max(name_width, max(len(r[0]) for r in results)) + + print_result(("Test", "Status", "Seconds", "Info"), name_width) + print_result(("----", "------", "-------", "----"), name_width) + + for resfile, results in result_lists: + print " (Result file: %s)" % resfile + for r in results: + print_result(r, name_width) -if __name__ == '__main__': +if __name__ == "__main__": import sys, os, glob - resfiles = glob.glob('../../results/default/status*') + resfiles = glob.glob("../../results/default/status*") if len(sys.argv) > 1: - if sys.argv[1] == '-h' or sys.argv[1] == '--help': - print 'Usage: %s [result files]' % sys.argv[0] + if sys.argv[1] == "-h" or sys.argv[1] == "--help": + print "Usage: %s [result files]" % sys.argv[0] sys.exit(0) resfiles = sys.argv[1:] main(resfiles) -- 1.5.4.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html