diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-10-04 15:36:47 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-10-07 09:37:35 +0100 |
commit | 3c5b6af99110bd7f64f5240a3e9d156f0593c497 (patch) | |
tree | 96761d7b52b99864076431c019c26efef6490d0d | |
parent | e57bd62e1772a7af52e7439ada8f94ddcadbf94f (diff) | |
download | ast2050-yocto-poky-3c5b6af99110bd7f64f5240a3e9d156f0593c497.zip ast2050-yocto-poky-3c5b6af99110bd7f64f5240a3e9d156f0593c497.tar.gz |
bitbake: bitbake-dumpsig: introduce command line and error handling
This utility doesn't take any special arguments, but it's nice if it at
least knows how to deal with no arguments, --help and errors properly.
(Bitbake rev: 0cabdf1d0cde6687bc1372675a0d6242587c87a0)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bitbake/bin/bitbake-dumpsig | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/bitbake/bin/bitbake-dumpsig b/bitbake/bin/bitbake-dumpsig index ccbc412..656d93a 100755 --- a/bitbake/bin/bitbake-dumpsig +++ b/bitbake/bin/bitbake-dumpsig @@ -1,11 +1,65 @@ #!/usr/bin/env python + +# bitbake-dumpsig +# BitBake task signature dump utility +# +# Copyright (C) 2013 Intel Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + import os import sys import warnings +import optparse +import logging + sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) import bb.siggen -output = bb.siggen.dump_sigfile(sys.argv[1]) -if output: - print '\n'.join(output) +def logger_create(name, output=sys.stderr): + logger = logging.getLogger(name) + console = logging.StreamHandler(output) + format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") + if output.isatty(): + format.enable_color() + console.setFormatter(format) + logger.addHandler(console) + logger.setLevel(logging.INFO) + return logger + +logger = logger_create('bitbake-dumpsig') + +parser = optparse.OptionParser( + description = "Dumps siginfo/sigdata files written out by BitBake", + usage = """ + %prog sigdatafile""") + +options, args = parser.parse_args(sys.argv) + +if len(args) == 1: + parser.print_help() +else: + import cPickle + try: + output = bb.siggen.dump_sigfile(args[1]) + except IOError as e: + logger.error(str(e)) + sys.exit(1) + except cPickle.UnpicklingError, EOFError: + logger.error('Invalid signature data - ensure you are specifying a sigdata/siginfo file') + sys.exit(1) + + if output: + print '\n'.join(output) |