summaryrefslogtreecommitdiffstats
path: root/scripts/pybootchartgui/pybootchartgui/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pybootchartgui/pybootchartgui/main.py')
l---------[-rw-r--r--]scripts/pybootchartgui/pybootchartgui/main.py79
1 files changed, 1 insertions, 78 deletions
diff --git a/scripts/pybootchartgui/pybootchartgui/main.py b/scripts/pybootchartgui/pybootchartgui/main.py
index e22636c23e..b45ae0a3d2 100644..120000
--- a/scripts/pybootchartgui/pybootchartgui/main.py
+++ b/scripts/pybootchartgui/pybootchartgui/main.py
@@ -1,78 +1 @@
1import sys main.py.in \ No newline at end of file
2import os
3import optparse
4
5import parsing
6import gui
7import batch
8
9def _mk_options_parser():
10 """Make an options parser."""
11 usage = "%prog [options] /path/to/tmp/buildstats/<recipe-machine>/<BUILDNAME>/"
12 version = "%prog v1.0.0"
13 parser = optparse.OptionParser(usage, version=version)
14 parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False,
15 help="start in active mode")
16 parser.add_option("-f", "--format", dest="format", default="svg", choices=["svg", "pdf", "png"],
17 help="image format: svg, pdf, png, [default: %default]")
18 parser.add_option("-o", "--output", dest="output", metavar="PATH", default=None,
19 help="output path (file or directory) where charts are stored")
20 parser.add_option("-s", "--split", dest="num", type=int, default=1,
21 help="split the output chart into <NUM> charts, only works with \"-o PATH\"")
22 parser.add_option("-m", "--mintime", dest="mintime", type=int, default=8,
23 help="only tasks longer than this time will be displayed")
24 parser.add_option("-n", "--no-prune", action="store_false", dest="prune", default=True,
25 help="do not prune the process tree")
26 parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False,
27 help="suppress informational messages")
28 parser.add_option("--very-quiet", action="store_true", dest="veryquiet", default=False,
29 help="suppress all messages except errors")
30 parser.add_option("--verbose", action="store_true", dest="verbose", default=False,
31 help="print all messages")
32 return parser
33
34def _get_filename(path):
35 """Construct a usable filename for outputs"""
36 dir = "."
37 file = "bootchart"
38 if os.path.isdir(path):
39 dir = path
40 elif path != None:
41 file = path
42 return os.path.join(dir, file)
43
44def main(argv=None):
45 try:
46 if argv is None:
47 argv = sys.argv[1:]
48
49 parser = _mk_options_parser()
50 options, args = parser.parse_args(argv)
51
52 if len(args) == 0:
53 parser.error("insufficient arguments, expected at least one path.")
54 return 2
55
56 res = parsing.parse(args, options.prune, options.mintime)
57 if options.interactive or options.output == None:
58 gui.show(res)
59 else:
60 filename = _get_filename(options.output)
61 res_list = parsing.split_res(res, options.num)
62 n = 1
63 for r in res_list:
64 if len(res_list) == 1:
65 f = filename + "." + options.format
66 else:
67 f = filename + "_" + str(n) + "." + options.format
68 n = n + 1
69 batch.render(r, options.format, f)
70 print "bootchart written to", f
71 return 0
72 except parsing.ParseError, ex:
73 print("Parse error: %s" % ex)
74 return 2
75
76
77if __name__ == '__main__':
78 sys.exit(main())