diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-07-31 15:59:59 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-08-03 14:47:31 +0100 |
commit | efe87ce4b2154c6f1c591ed9d8f770c229b044ad (patch) | |
tree | 1004b72bb3e3a8cb5f2bc75242d37e0decc28b60 /meta/lib | |
parent | 908cdd669b083b172f7cd53dd020629affee360c (diff) | |
download | openembedded-core-contrib-efe87ce4b2154c6f1c591ed9d8f770c229b044ad.tar.gz |
classes/lib: Remove bb.build.FuncFailed
Whilst seemingly a good idea, this exception doesn't really serve any purpose
that bb.fatal() doesn't cover. Wrapping exceptions within exceptions isn't
pythonic.
Its not used in many places, lets clean up those and remove usage of it
entirely. It may ultimately be dropped form bitbake entirely.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/gpg_sign.py | 5 | ||||
-rw-r--r-- | meta/lib/oe/useradd.py | 2 | ||||
-rw-r--r-- | meta/lib/oe/utils.py | 2 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/bbtests.py | 7 | ||||
-rw-r--r-- | meta/lib/oeqa/targetcontrol.py | 4 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/commands.py | 4 |
6 files changed, 13 insertions, 11 deletions
diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py index 2fd8c3b1ac3..d7624804d53 100644 --- a/meta/lib/oe/gpg_sign.py +++ b/meta/lib/oe/gpg_sign.py @@ -89,8 +89,7 @@ class LocalSigner(object): (_, stderr) = job.communicate(passphrase.encode("utf-8")) if job.returncode: - raise bb.build.FuncFailed("GPG exited with code %d: %s" % - (job.returncode, stderr.decode("utf-8"))) + bb.fatal("GPG exited with code %d: %s" % (job.returncode, stderr.decode("utf-8"))) except IOError as e: bb.error("IO error (%s): %s" % (e.errno, e.strerror)) @@ -108,7 +107,7 @@ class LocalSigner(object): ver_str = subprocess.check_output(cmd).split()[2].decode("utf-8") return tuple([int(i) for i in ver_str.split("-")[0].split('.')]) except subprocess.CalledProcessError as e: - raise bb.build.FuncFailed("Could not get gpg version: %s" % e) + bb.fatal("Could not get gpg version: %s" % e) def verify(self, sig_file): diff --git a/meta/lib/oe/useradd.py b/meta/lib/oe/useradd.py index bedfe0ecb53..8fc77568ff9 100644 --- a/meta/lib/oe/useradd.py +++ b/meta/lib/oe/useradd.py @@ -14,7 +14,7 @@ class myArgumentParser(argparse.ArgumentParser): error(message) def error(self, message): - raise bb.build.FuncFailed(message) + bb.fatal(message) def split_commands(params): params = re.split('''[ \t]*;[ \t]*(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', params.strip()) diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index d686ce1bf61..652b2be145e 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py @@ -486,7 +486,7 @@ def write_ld_so_conf(d): f.write(d.getVar("base_libdir") + '\n') f.write(d.getVar("libdir") + '\n') -class ImageQAFailed(bb.build.FuncFailed): +class ImageQAFailed(Exception): def __init__(self, description, name=None, logfile=None): self.description = description self.name = name diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py index 17da0fd32c7..0693ba8cf8f 100644 --- a/meta/lib/oeqa/selftest/cases/bbtests.py +++ b/meta/lib/oeqa/selftest/cases/bbtests.py @@ -75,8 +75,11 @@ class BitbakeTests(OESelftestTestCase): result = bitbake('man-db -c patch', ignore_status=True) self.delete_recipeinc('man-db') bitbake('-cclean man-db') - line = self.getline(result, "Function failed: patch_do_patch") - self.assertTrue(line and line.startswith("ERROR:"), msg = "Incorrectly formed patch application didn't fail. bitbake output: %s" % result.output) + found = False + for l in result.output.split('\n'): + if l.startswith("ERROR:") and "failed" in l and "do_patch" in l: + found = l + self.assertTrue(found and found.startswith("ERROR:"), msg = "Incorrectly formed patch application didn't fail. bitbake output: %s" % result.output) def test_force_task_1(self): # test 1 from bug 5875 diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py index 15e617c95a9..1445e3ecfb9 100644 --- a/meta/lib/oeqa/targetcontrol.py +++ b/meta/lib/oeqa/targetcontrol.py @@ -175,7 +175,7 @@ class QemuTarget(BaseTarget): if os.path.exists(self.qemulog): with open(self.qemulog, 'r') as f: bb.error("Qemu log output from %s:\n%s" % (self.qemulog, f.read())) - raise bb.build.FuncFailed("%s - FAILED to start qemu - check the task log and the boot log" % self.pn) + raise RuntimeError("%s - FAILED to start qemu - check the task log and the boot log" % self.pn) def check(self): return self.runner.is_alive() @@ -192,7 +192,7 @@ class QemuTarget(BaseTarget): self.server_ip = self.runner.server_ip self.connection = SSHControl(ip=self.ip, logfile=self.sshlog) else: - raise bb.build.FuncFailed("%s - FAILED to re-start qemu - check the task log and the boot log" % self.pn) + raise RuntimError("%s - FAILED to re-start qemu - check the task log and the boot log" % self.pn) def run_serial(self, command, timeout=60): return self.runner.run_serial(command, timeout=timeout) diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 59ebfbe1253..7140bc73d24 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -337,8 +337,8 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemu.deploy() try: qemu.start(params=qemuparams, ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd, discard_writes=discard_writes) - except bb.build.FuncFailed: - msg = 'Failed to start QEMU - see the logs in %s' % logdir + except EXception as e: + msg = str(e) + '\nFailed to start QEMU - see the logs in %s' % logdir if os.path.exists(qemu.qemurunnerlog): with open(qemu.qemurunnerlog, 'r') as f: msg = msg + "Qemurunner log output from %s:\n%s" % (qemu.qemurunnerlog, f.read()) |