summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-10-04 15:36:47 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-10-07 09:37:35 +0100
commit3c5b6af99110bd7f64f5240a3e9d156f0593c497 (patch)
tree96761d7b52b99864076431c019c26efef6490d0d /bitbake
parente57bd62e1772a7af52e7439ada8f94ddcadbf94f (diff)
downloadpoky-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>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/bitbake-dumpsig60
1 files changed, 57 insertions, 3 deletions
diff --git a/bitbake/bin/bitbake-dumpsig b/bitbake/bin/bitbake-dumpsig
index ccbc412583..656d93a5ac 100755
--- a/bitbake/bin/bitbake-dumpsig
+++ b/bitbake/bin/bitbake-dumpsig
@@ -1,11 +1,65 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2
3# bitbake-dumpsig
4# BitBake task signature dump utility
5#
6# Copyright (C) 2013 Intel Corporation
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License version 2 as
10# published by the Free Software Foundation.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program; if not, write to the Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
2import os 21import os
3import sys 22import sys
4import warnings 23import warnings
24import optparse
25import logging
26
5sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) 27sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
6 28
7import bb.siggen 29import bb.siggen
8 30
9output = bb.siggen.dump_sigfile(sys.argv[1]) 31def logger_create(name, output=sys.stderr):
10if output: 32 logger = logging.getLogger(name)
11 print '\n'.join(output) 33 console = logging.StreamHandler(output)
34 format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
35 if output.isatty():
36 format.enable_color()
37 console.setFormatter(format)
38 logger.addHandler(console)
39 logger.setLevel(logging.INFO)
40 return logger
41
42logger = logger_create('bitbake-dumpsig')
43
44parser = optparse.OptionParser(
45 description = "Dumps siginfo/sigdata files written out by BitBake",
46 usage = """
47 %prog sigdatafile""")
48
49options, args = parser.parse_args(sys.argv)
50
51if len(args) == 1:
52 parser.print_help()
53else:
54 import cPickle
55 try:
56 output = bb.siggen.dump_sigfile(args[1])
57 except IOError as e:
58 logger.error(str(e))
59 sys.exit(1)
60 except cPickle.UnpicklingError, EOFError:
61 logger.error('Invalid signature data - ensure you are specifying a sigdata/siginfo file')
62 sys.exit(1)
63
64 if output:
65 print '\n'.join(output)