From patchwork Mon May 17 13:29:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 100120 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4HDUwTq008505 for ; Mon, 17 May 2010 13:30:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755382Ab0EQNaZ (ORCPT ); Mon, 17 May 2010 09:30:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64557 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752242Ab0EQNaW (ORCPT ); Mon, 17 May 2010 09:30:22 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4HDUI6S003618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 May 2010 09:30:18 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4HDUIXe027593; Mon, 17 May 2010 09:30:18 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o4HDUGA2029225; Mon, 17 May 2010 09:30:16 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: formatting improvements to scan_results.py Date: Mon, 17 May 2010 16:29:33 +0300 Message-Id: <1274102975-32453-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 17 May 2010 13:30:59 +0000 (UTC) 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)