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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is useful for printing results of several jobs executing in parallel
(using job.parallel()).

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

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)
-- 
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

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux