diff mbox

[03/19] KVM test: scan_results.py: allow parsing and printing of multiple result files

Message ID 1252519932-30733-3-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Sept. 9, 2009, 6:11 p.m. UTC
This is useful for printing results of several jobs executing in parallel
(using job.parallel()).

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/scan_results.py |   42 +++++++++++++++++++------------------
 1 files changed, 22 insertions(+), 20 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/scan_results.py b/client/tests/kvm/scan_results.py
index 95507bd..a22634e 100755
--- a/client/tests/kvm/scan_results.py
+++ b/client/tests/kvm/scan_results.py
@@ -51,28 +51,30 @@  def print_result(result):
         print '%-48s\t\t%s\t%s\t%s' % tuple(map(str, result))
 
 
-def main(resfile):
-    print_result(('test', 'status', 'seconds', 'info'))
+def main(resfiles):
+    print_result(('Test', 'Status', 'Seconds', 'Info'))
     print_result(('----', '------', '-------', '----'))
 
-    f = file(resfile)
-    text = f.read()
-    f.close()
-
-    results = parse_results(text)
-    map(print_result, results)
+    for resfile in resfiles:
+        print '        (Result file: %s)' % resfile
+        try:
+            f = file(resfile)
+            text = f.read()
+            f.close()
+        except IOError:
+            print 'Bad result file: %s' % resfile
+            return
+        results = parse_results(text)
+        map(print_result, results)
 
 
 if __name__ == '__main__':
-    import sys, os
-
-    resfile = '../../results/default/status'
-    if len(sys.argv) == 2:
-        resfile = sys.argv[1]
-    if resfile == '-h' or resfile == '--help' or len(sys.argv) > 2:
-        print 'usage: %s [ <resfile> ]' % sys.argv[0]
-        sys.exit(0)
-    if not os.path.exists(resfile):
-        print 'Bad result file: %s' % resfile
-        sys.exit(1)
-    main(resfile)
+    import sys, os, glob
+
+    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]
+            sys.exit(0)
+        resfiles = sys.argv[1:]
+    main(resfiles)