summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/pybootchartgui/pybootchartgui/main.py33
1 files changed, 14 insertions, 19 deletions
diff --git a/scripts/pybootchartgui/pybootchartgui/main.py b/scripts/pybootchartgui/pybootchartgui/main.py
index fce8dd35cf..e70ab13661 100644
--- a/scripts/pybootchartgui/pybootchartgui/main.py
+++ b/scripts/pybootchartgui/pybootchartgui/main.py
@@ -8,13 +8,13 @@ import batch
8 8
9def _mk_options_parser(): 9def _mk_options_parser():
10 """Make an options parser.""" 10 """Make an options parser."""
11 usage = "%prog [options] PATH, ..., PATH" 11 usage = "%prog [options] /path/to/tmp/buildstats/<recipe-machine>/<BUILDNAME>/"
12 version = "%prog v0.0.0" 12 version = "%prog v1.0.0"
13 parser = optparse.OptionParser(usage, version=version) 13 parser = optparse.OptionParser(usage, version=version)
14 parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, 14 parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False,
15 help="start in active mode") 15 help="start in active mode")
16 parser.add_option("-f", "--format", dest="format", default = None, 16 parser.add_option("-f", "--format", dest="format", default="svg", choices=["svg", "pdf", "png"],
17 help="image format (...); default format ...") 17 help="image format: svg, pdf, png, [default: %default]")
18 parser.add_option("-o", "--output", dest="output", metavar="PATH", default=None, 18 parser.add_option("-o", "--output", dest="output", metavar="PATH", default=None,
19 help="output path (file or directory) where charts are stored") 19 help="output path (file or directory) where charts are stored")
20 parser.add_option("-s", "--split", dest="num", type=int, default=1, 20 parser.add_option("-s", "--split", dest="num", type=int, default=1,
@@ -29,20 +29,15 @@ def _mk_options_parser():
29 help="print all messages") 29 help="print all messages")
30 return parser 30 return parser
31 31
32def _get_filename(paths, options): 32def _get_filename(path):
33 """Construct a usable filename for outputs based on the paths and options given on the commandline.""" 33 """Construct a usable filename for outputs"""
34 dir = "" 34 dir = "."
35 file = "bootchart" 35 file = "bootchart"
36 if options.output != None and not(os.path.isdir(options.output)): 36 if os.path.isdir(path):
37 return options.output 37 dir = path
38 if options.output != None: 38 elif path != None:
39 dir = options.output 39 file = path
40 if len(paths) == 1: 40 return os.path.join(dir, file)
41 if os.path.isdir(paths[0]):
42 file = os.path.split(paths[0])[-1]
43 elif os.path.splitext(paths[0])[1] in [".tar", ".tgz", ".tar.gz"]:
44 file = os.path.splitext(paths[0])[0]
45 return os.path.join(dir, file + "." + options.format)
46 41
47def main(argv=None): 42def main(argv=None):
48 try: 43 try:
@@ -57,10 +52,10 @@ def main(argv=None):
57 return 2 52 return 2
58 53
59 res = parsing.parse(args, options.prune) 54 res = parsing.parse(args, options.prune)
60 if options.interactive or options.format == None: 55 if options.interactive or options.output == None:
61 gui.show(res) 56 gui.show(res)
62 else: 57 else:
63 filename = _get_filename(args, options) 58 filename = _get_filename(options.output)
64 res_list = parsing.split_res(res, options.num) 59 res_list = parsing.split_res(res, options.num)
65 n = 1 60 n = 1
66 for r in res_list: 61 for r in res_list: