summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2012-06-06 14:14:39 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-06-15 15:12:43 +0100
commit1b112fa9cf0f0a3efe022e68d3ad1575c8b9de74 (patch)
tree2dd9334204d43ce5efba8ed17dffeea89b4e34ea /scripts
parent0ad3f754324eb6337243ca7d28f32b047eca0b51 (diff)
downloadpoky-1b112fa9cf0f0a3efe022e68d3ad1575c8b9de74.tar.gz
pybootchartgui: Fix the filename and add a default format
* Fix teh output filename to make it easy to use * Add a default output format (svg) * Fix the usage message * Fix the version to v1.0.0 Currently, the help messages are: $ ./pybootchartgui.py --help Usage: pybootchartgui.py [options] /path/to/tmp/buildstats/<recipe-machine>/<BUILDNAME>/ Options: --version show program's version number and exit -h, --help show this help message and exit -i, --interactive start in active mode -f FORMAT, --format=FORMAT image format: svg, pdf, png, [default: svg] -o PATH, --output=PATH output path (file or directory) where charts are stored -s NUM, --split=NUM split the output chart into <NUM> charts, only works with "-o PATH" -n, --no-prune do not prune the process tree -q, --quiet suppress informational messages --very-quiet suppress all messages except errors --verbose print all messages [YOCTO #2403] (From OE-Core rev: 138c2c31e41e3f1803b7efbedf78326d71821468) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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: