summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-10-04 15:35:29 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-10-07 08:37:35 (GMT)
commite57bd62e1772a7af52e7439ada8f94ddcadbf94f (patch)
treef03720f795db03690b89d09f0e8693408f5efb78
parente0e30c6239c73f5c2f3b6b7500e992f677a6f3c1 (diff)
downloadpoky-e57bd62e1772a7af52e7439ada8f94ddcadbf94f.tar.gz
bitbake: bitbake-diffsigs: improve error handling
* Set up a logger independent of BitBake so we can log errors ourselves * Handle common errors without printing a traceback (Bitbake rev: 77b5f5b8dca4deebb06eeb06a8e7f2ccdbfff46f) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/bin/bitbake-diffsigs30
1 files changed, 25 insertions, 5 deletions
diff --git a/bitbake/bin/bitbake-diffsigs b/bitbake/bin/bitbake-diffsigs
index 11b40b4..78757b0 100755
--- a/bitbake/bin/bitbake-diffsigs
+++ b/bitbake/bin/bitbake-diffsigs
@@ -3,7 +3,7 @@
3# bitbake-diffsigs 3# bitbake-diffsigs
4# BitBake task signature data comparison utility 4# BitBake task signature data comparison utility
5# 5#
6# Copyright (C) 2012 Intel Corporation 6# Copyright (C) 2012-2013 Intel Corporation
7# 7#
8# This program is free software; you can redistribute it and/or modify 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 9# it under the terms of the GNU General Public License version 2 as
@@ -30,7 +30,18 @@ sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), '
30import bb.tinfoil 30import bb.tinfoil
31import bb.siggen 31import bb.siggen
32 32
33logger = logging.getLogger('BitBake') 33def logger_create(name, output=sys.stderr):
34 logger = logging.getLogger(name)
35 console = logging.StreamHandler(output)
36 format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
37 if output.isatty():
38 format.enable_color()
39 console.setFormatter(format)
40 logger.addHandler(console)
41 logger.setLevel(logging.INFO)
42 return logger
43
44logger = logger_create('bitbake-diffsigs')
34 45
35def find_compare_task(bbhandler, pn, taskname): 46def find_compare_task(bbhandler, pn, taskname):
36 """ Find the most recent signature files for the specified PN/task and compare them """ 47 """ Find the most recent signature files for the specified PN/task and compare them """
@@ -93,10 +104,19 @@ if options.taskargs:
93else: 104else:
94 if len(args) == 1: 105 if len(args) == 1:
95 parser.print_help() 106 parser.print_help()
96 elif len(args) == 2:
97 output = bb.siggen.dump_sigfile(sys.argv[1])
98 else: 107 else:
99 output = bb.siggen.compare_sigfiles(sys.argv[1], sys.argv[2]) 108 import cPickle
109 try:
110 if len(args) == 2:
111 output = bb.siggen.dump_sigfile(sys.argv[1])
112 else:
113 output = bb.siggen.compare_sigfiles(sys.argv[1], sys.argv[2])
114 except IOError as e:
115 logger.error(str(e))
116 sys.exit(1)
117 except cPickle.UnpicklingError, EOFError:
118 logger.error('Invalid signature data - ensure you are specifying sigdata/siginfo files')
119 sys.exit(1)
100 120
101 if output: 121 if output:
102 print '\n'.join(output) 122 print '\n'.join(output)