mirror of
https://git.yoctoproject.org/poky
synced 2026-04-22 06:32:12 +02:00
pybootchartgui: add the original code
This is from: http://pybootchartgui.googlecode.com/files/pybootchartgui-r124.tar.gz Will modify it to make the build profiling in pictures. Remove the examples since they would not work any more, and they cost much disk space. [YOCTO #2403] (From OE-Core rev: 1f0791109e1aed715f02945834d6d7fdb9a411b4) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
bc19f8bc9c
commit
3d78bc19c5
71
scripts/pybootchartgui/pybootchartgui/main.py
Normal file
71
scripts/pybootchartgui/pybootchartgui/main.py
Normal file
@@ -0,0 +1,71 @@
|
||||
import sys
|
||||
import os
|
||||
import optparse
|
||||
|
||||
import parsing
|
||||
import gui
|
||||
import batch
|
||||
|
||||
def _mk_options_parser():
|
||||
"""Make an options parser."""
|
||||
usage = "%prog [options] PATH, ..., PATH"
|
||||
version = "%prog v0.0.0"
|
||||
parser = optparse.OptionParser(usage, version=version)
|
||||
parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False,
|
||||
help="start in active mode")
|
||||
parser.add_option("-f", "--format", dest="format", default = None,
|
||||
help="image format (...); default format ...")
|
||||
parser.add_option("-o", "--output", dest="output", metavar="PATH", default=None,
|
||||
help="output path (file or directory) where charts are stored")
|
||||
parser.add_option("-n", "--no-prune", action="store_false", dest="prune", default=True,
|
||||
help="do not prune the process tree")
|
||||
parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False,
|
||||
help="suppress informational messages")
|
||||
parser.add_option("--very-quiet", action="store_true", dest="veryquiet", default=False,
|
||||
help="suppress all messages except errors")
|
||||
parser.add_option("--verbose", action="store_true", dest="verbose", default=False,
|
||||
help="print all messages")
|
||||
return parser
|
||||
|
||||
def _get_filename(paths, options):
|
||||
"""Construct a usable filename for outputs based on the paths and options given on the commandline."""
|
||||
dir = ""
|
||||
file = "bootchart"
|
||||
if options.output != None and not(os.path.isdir(options.output)):
|
||||
return options.output
|
||||
if options.output != None:
|
||||
dir = options.output
|
||||
if len(paths) == 1:
|
||||
if os.path.isdir(paths[0]):
|
||||
file = os.path.split(paths[0])[-1]
|
||||
elif os.path.splitext(paths[0])[1] in [".tar", ".tgz", ".tar.gz"]:
|
||||
file = os.path.splitext(paths[0])[0]
|
||||
return os.path.join(dir, file + "." + options.format)
|
||||
|
||||
def main(argv=None):
|
||||
try:
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
|
||||
parser = _mk_options_parser()
|
||||
options, args = parser.parse_args(argv)
|
||||
|
||||
if len(args) == 0:
|
||||
parser.error("insufficient arguments, expected at least one path.")
|
||||
return 2
|
||||
|
||||
res = parsing.parse(args, options.prune)
|
||||
if options.interactive or options.format == None:
|
||||
gui.show(res)
|
||||
else:
|
||||
filename = _get_filename(args, options)
|
||||
batch.render(res, options.format, filename)
|
||||
print "bootchart written to", filename
|
||||
return 0
|
||||
except parsing.ParseError, ex:
|
||||
print("Parse error: %s" % ex)
|
||||
return 2
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user