]> code.ossystems Code Review - openembedded-core.git/commitdiff
classes/lib: Remove bb.build.FuncFailed
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 31 Jul 2019 14:59:59 +0000 (15:59 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 3 Aug 2019 13:47:31 +0000 (14:47 +0100)
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>
meta/classes/go.bbclass
meta/classes/image.bbclass
meta/lib/oe/gpg_sign.py
meta/lib/oe/useradd.py
meta/lib/oe/utils.py
meta/lib/oeqa/selftest/cases/bbtests.py
meta/lib/oeqa/targetcontrol.py
meta/lib/oeqa/utils/commands.py

index f303a15eaf3441f16283abe5c99e12dfe09921e7..e40e55689ddb11a2cbd656e449f10ae2da710774 100644 (file)
@@ -71,17 +71,13 @@ python go_do_unpack() {
     if len(src_uri) == 0:
         return
 
-    try:
-        fetcher = bb.fetch2.Fetch(src_uri, d)
-        for url in fetcher.urls:
-            if fetcher.ud[url].type == 'git':
-                if fetcher.ud[url].parm.get('destsuffix') is None:
-                    s_dirname = os.path.basename(d.getVar('S'))
-                    fetcher.ud[url].parm['destsuffix'] = os.path.join(s_dirname, 'src',
-                                                                      d.getVar('GO_IMPORT')) + '/'
-        fetcher.unpack(d.getVar('WORKDIR'))
-    except bb.fetch2.BBFetchException as e:
-        raise bb.build.FuncFailed(e)
+    fetcher = bb.fetch2.Fetch(src_uri, d)
+    for url in fetcher.urls:
+        if fetcher.ud[url].type == 'git':
+            if fetcher.ud[url].parm.get('destsuffix') is None:
+                s_dirname = os.path.basename(d.getVar('S'))
+                fetcher.ud[url].parm['destsuffix'] = os.path.join(s_dirname, 'src', d.getVar('GO_IMPORT')) + '/'
+    fetcher.unpack(d.getVar('WORKDIR'))
 }
 
 go_list_packages() {
index 682858dc957329d57851131fa67f4037b841ba64..7fa4ff20bd3a96493b1e23141a81c46edcb94c4d 100644 (file)
@@ -305,11 +305,8 @@ fakeroot python do_image_qa () {
             bb.build.exec_func(cmd, d)
         except oe.utils.ImageQAFailed as e:
             qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
-        except bb.build.FuncFailed as e:
-            qamsg = qamsg + '\tImage QA function %s failed' % e.name
-            if e.logfile:
-                qamsg = qamsg + ' (log file is located at %s)' % e.logfile
-            qamsg = qamsg + '\n'
+        except Exception as e:
+            qamsg = qamsg + '\tImage QA function %s failed\n' % cmd
 
     if qamsg:
         imgname = d.getVar('IMAGE_NAME')
index 2fd8c3b1ac3dcc9370ba73a0d161f6324de573dc..d7624804d532c35ed99c1301d688ed2eb97260fd 100644 (file)
@@ -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):
index bedfe0ecb536d633ea3fe10bb05637c795279e72..8fc77568ff9930045be556c9508d22c5252f087d 100644 (file)
@@ -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())
index d686ce1bf6166713311ab0e2ca29468fa7eecf2b..652b2be145e63627555c96b4129acc27fe5bbe51 100644 (file)
@@ -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
index 17da0fd32c76c98087c702f31984f21ff51881f6..0693ba8cf8fb344aba65eac1012a0edaa6b29929 100644 (file)
@@ -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
index 15e617c95a99843e02d2d505d81cc55ed1bfd17b..1445e3ecfb9b44362c75cfe7976148330f68a65a 100644 (file)
@@ -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)
index 59ebfbe1253e561e494e2c09a8c46156014f623d..7140bc73d24b8d375036d42a261a52879ffeb653 100644 (file)
@@ -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())