5 from autotest_lib
.cli
import rpc
9 usage
= "usage: %prog [options] job_id"
10 parser
= optparse
.OptionParser(usage
=usage
)
11 parser
.add_option("-m", "--machine", dest
="machine")
12 parser
.add_option("-t", "--test", dest
="test")
13 parser
.add_option("-T", "--type", dest
="type", type="choice",
14 choices
=["all", "test", "iteration", "attr", "perf"])
15 parser
.add_option("-k", "--key", dest
="key")
16 parser
.set_defaults(type="all")
17 options
, args
= parser
.parse_args()
18 options
.show_test_keyvals
= options
.type in ("all", "test")
19 options
.show_attr_keyvals
= options
.type in ("all", "iteration", "attr")
20 options
.show_perf_keyvals
= options
.type in ("all", "iteration", "perf")
21 options
.show_iter_keyvals
= (
22 options
.show_perf_keyvals
or options
.show_attr_keyvals
)
23 return parser
, options
, args
26 def print_keyvals(keyval
, format_string
, options
):
27 for key
, value
in keyval
.iteritems():
28 if not options
.key
or key
== options
.key
:
29 print format_string
% (key
, value
)
32 def print_views(test_views
, options
):
33 for view
in test_views
:
34 if not options
.machine
:
35 print "Machine: %s" % view
["hostname"]
37 print "Test: %s" % view
["test_name"]
38 if options
.show_test_keyvals
:
39 print "Test Attributes:"
40 print_keyvals(view
["attributes"], "\t%s = %s", options
)
41 if options
.show_iter_keyvals
:
42 print "Iteration Attributes:"
43 for i
, iteration
in enumerate(view
["iterations"]):
44 print "\tIteration #%d:" % (i
+ 1)
45 if options
.show_attr_keyvals
:
46 print_keyvals(iteration
["attr"], "\t\t%s(attr) = %s",
48 if options
.show_perf_keyvals
:
49 print_keyvals(iteration
["perf"], "\t\t%s(perf) = %s",
55 parser
, options
, args
= parse_options()
62 query_filter
["hostname"] = options
.machine
64 query_filter
["test_name"] = options
.test
69 query_filter
["job_tag__startswith"] = "%s-" % job_id
70 test_views
+= comm
.run("get_detailed_test_views", **query_filter
)
71 print_views(test_views
, options
)
74 if __name__
== "__main__":