[2.2][PATCH 1/4] utils: Allow to_boolean to support int values
From: Richard Purdie <[email protected]>
Some variables may be set as:
X = 1
as well the more usual
X = "1"
so add support to to_boolean to handle this case.
--- lib/bb/utils.py | 3 +++ 1 file changed, 3 insertions(+)
lib/bb/utils.py +3 -0
@@ -992,6 +992,9 @@ def to_boolean(string, default=None): if not string: return default + if isinstance(string, int): + return string != 0 + normalized = string.lower() if normalized in ("y", "yes", "1", "true"): return True
Signature · 1 line
2.39.2
[2.2][PATCH 2/4] cookerdata: Remove incorrect SystemExit usage
From: Richard Purdie <[email protected]>
Calling SystemExit doesn't work well with server/client usage since the string isn't printed to the right place. Use bb.fatal() instead which prints the right log output and raises and handled exception which then shows correctly on the UI.
--- lib/bb/cookerdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/cookerdata.py +1 -1
@@ -436,7 +436,7 @@ class CookerDataBuilder(object): msg += (" and bitbake did not find a conf/bblayers.conf file in" " the expected location.\nMaybe you accidentally" " invoked bitbake from the wrong directory?") - raise SystemExit(msg) + bb.fatal(msg) if not data.getVar("TOPDIR"): data.setVar("TOPDIR", os.path.abspath(os.getcwd()))
Signature · 1 line
2.39.2
[2.2][PATCH 3/4] cookerdata: Improve early exception handling
In reply to Martin JansaFrom: Richard Purdie <[email protected]>
Martin Jansa reported that if you put a syntax error into an imported module such as qa.py in OE, no error is shown.
Part of the issue appears to be that the catch_parse_error() decorator only catches certain exceptions and SyntaxError isn't one of them. As far as I can tell we should remove all the special cases and use the more advanced code in all cases, not just expansion errors.
I confirmed this now prints a proper error message for a qa.py syntax error.
--- lib/bb/cookerdata.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
lib/bb/cookerdata.py +1 -9
@@ -160,12 +160,7 @@ def catch_parse_error(func): def wrapped(fn, *args): try: return func(fn, *args) - except IOError as exc: - import traceback - parselog.critical(traceback.format_exc()) - parselog.critical("Unable to parse %s: %s" % (fn, exc)) - raise bb.BBHandledException() - except bb.data_smart.ExpansionError as exc: + except Exception as exc: import traceback bbdir = os.path.dirname(__file__) + os.sep
@@ -177,9 +172,6 @@ def catch_parse_error(func): break parselog.critical("Unable to parse %s" % fn, exc_info=(exc_class, exc, tb)) raise bb.BBHandledException() - except bb.parse.ParseError as exc: - parselog.critical(str(exc)) - raise bb.BBHandledException() return wrapped @catch_parse_error
Signature · 1 line
2.39.2
[2.2][PATCH 4/4] cookerdata: Drop dubious exception handling code
In reply to Martin JansaFrom: Richard Purdie <[email protected]>
This code appears to be dangerous, it swallows exceptions, turning them into "handled" versions which then show no errors to the user. This is a pretty poor user experience and I can't see why this code should be swallowing such things. Drop the worst bits of code.
--- lib/bb/cookerdata.py | 5 ----- 1 file changed, 5 deletions(-)
lib/bb/cookerdata.py +0 -5
@@ -294,14 +294,9 @@ class CookerDataBuilder(object): bb.event.fire(bb.event.MultiConfigParsed(self.mcdata), self.data) self.data_hash = data_hash.hexdigest() - except (SyntaxError, bb.BBHandledException): - raise bb.BBHandledException() except bb.data_smart.ExpansionError as e: logger.error(str(e)) raise bb.BBHandledException() - except Exception: - logger.exception("Error parsing configuration files") - raise bb.BBHandledException() # Handle obsolete variable names
Signature · 1 line
2.39.2