From f5ae79da406190bf27194d7cecf15926bbb6ef20 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Tue, 14 Feb 2017 22:21:38 +0200 Subject: wic: raise WicError in core modules Replaced sys.exit with raising WicError in the core wic modules. (From OE-Core rev: 1b11437fb25ece5b3eede52344b071e875fa738f) Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- scripts/lib/wic/engine.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'scripts/lib/wic/engine.py') diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index 2ccd5107f3..38a68ed340 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py @@ -30,8 +30,8 @@ import logging import os -import sys +from wic.errors import WicError from wic.plugin import pluginmgr from wic.utils.misc import get_bitbake_var @@ -44,8 +44,7 @@ def verify_build_env(): Returns True if it is, false otherwise """ if not os.environ.get("BUILDDIR"): - logger.error("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)") - sys.exit(1) + raise WicError("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)") return True @@ -180,8 +179,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, try: oe_builddir = os.environ["BUILDDIR"] except KeyError: - logger.error("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)") - sys.exit(1) + raise WicError("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)") if not os.path.exists(options.outdir): os.makedirs(options.outdir) @@ -189,8 +187,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, pname = 'direct' plugin_class = pluginmgr.get_plugins('imager').get(pname) if not plugin_class: - logger.error('Unknown plugin: %s', pname) - sys.exit(1) + raise WicError('Unknown plugin: %s' % pname) plugin = plugin_class(wks_file, rootfs_dir, bootimg_dir, kernel_dir, native_sysroot, oe_builddir, options) @@ -217,11 +214,11 @@ def wic_list(args, scripts_path): wks_file = args[0] fullpath = find_canned_image(scripts_path, wks_file) if not fullpath: - logger.error("No image named %s found, exiting. " - "(Use 'wic list images' to list available images, or " - "specify a fully-qualified OE kickstart (.wks) " - "filename)\n", wks_file) - sys.exit(1) + raise WicError("No image named %s found, exiting. " + "(Use 'wic list images' to list available images, " + "or specify a fully-qualified OE kickstart (.wks) " + "filename)" % wks_file) + list_canned_image_help(scripts_path, fullpath) return True -- cgit v1.2.3-54-g00ecf