aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-02 23:12:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-03 12:24:10 +0100
commit91699f366d24480ff3b19faec78fb9f3181b3e14 (patch)
tree935a54992730dd24bbd1d3c9df01e4b7e275bfef
parent3a2503c785a5cd9dca0dc68c3aec31b4bec7684b (diff)
downloadbitbake-91699f366d24480ff3b19faec78fb9f3181b3e14.tar.gz
cooker/cookerdata: Use BBHandledException, not sys.exit()
Calling sys.exit() in the middle of the code is rather antisocial. We catch this in various places but we shouldn't have to. In all these cases we have already sent events explaining to the user what happened. This means the correct exception is BBHandledException. The recent startup changes have moved the point a lot of this code gets called to inside the UI, with memres it would have always been possible from there anyway. This change makes things much more consistent. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/cooker.py4
-rw-r--r--lib/bb/cookerdata.py10
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index fc017dd19..a85e3587f 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -352,7 +352,7 @@ class BBCooker:
self.caches_array.append(getattr(module, cache_name))
except ImportError as exc:
logger.critical("Unable to import extra RecipeInfo '%s' from '%s': %s" % (cache_name, module_name, exc))
- sys.exit("FATAL: Failed to import extra cache class '%s'." % cache_name)
+ raise bb.BBHandledException()
self.databuilder = bb.cookerdata.CookerDataBuilder(self.configuration, False)
self.databuilder.parseBaseConfiguration()
@@ -1127,7 +1127,7 @@ class BBCooker:
from bb import shell
except ImportError:
parselog.exception("Interactive mode not available")
- sys.exit(1)
+ raise bb.BBHandledException()
else:
shell.start( self )
diff --git a/lib/bb/cookerdata.py b/lib/bb/cookerdata.py
index 190ff3ab8..48953a830 100644
--- a/lib/bb/cookerdata.py
+++ b/lib/bb/cookerdata.py
@@ -164,7 +164,7 @@ def catch_parse_error(func):
import traceback
parselog.critical(traceback.format_exc())
parselog.critical("Unable to parse %s: %s" % (fn, exc))
- sys.exit(1)
+ raise bb.BBHandledException()
except bb.data_smart.ExpansionError as exc:
import traceback
@@ -176,10 +176,10 @@ def catch_parse_error(func):
if not fn.startswith(bbdir):
break
parselog.critical("Unable to parse %s" % fn, exc_info=(exc_class, exc, tb))
- sys.exit(1)
+ raise bb.BBHandledException()
except bb.parse.ParseError as exc:
parselog.critical(str(exc))
- sys.exit(1)
+ raise bb.BBHandledException()
return wrapped
@catch_parse_error
@@ -355,7 +355,7 @@ class CookerDataBuilder(object):
for layer in broken_layers:
parselog.critical(" %s", layer)
parselog.critical("Please check BBLAYERS in %s" % (layerconf))
- sys.exit(1)
+ raise bb.BBHandledException()
for layer in layers:
parselog.debug(2, "Adding layer %s", layer)
@@ -427,7 +427,7 @@ class CookerDataBuilder(object):
handlerfn = data.getVarFlag(var, "filename", False)
if not handlerfn:
parselog.critical("Undefined event handler function '%s'" % var)
- sys.exit(1)
+ raise bb.BBHandledException()
handlerln = int(data.getVarFlag(var, "lineno", False))
bb.event.register(var, data.getVar(var, False), (data.getVarFlag(var, "eventmask") or "").split(), handlerfn, handlerln)