diff mbox series

bitbake-getvar: Catch NoProvider exception

Message ID 20241119195801.16071-1-bhstalel@gmail.com
State Accepted, archived
Commit 06aa6c292813a28c84736193b550fb2d18884d43
Headers show
Series bitbake-getvar: Catch NoProvider exception | expand

Commit Message

Talel BELHAJSALEM Nov. 19, 2024, 7:58 p.m. UTC
When the recipe provided by (-r, --recipe) is not found
tinfoil raises an exception that is not catched for
readability, example:

Traceback (most recent call last):
  File "/.../poky/bitbake/bin/bitbake-getvar", line 45, in <module>
    d = tinfoil.parse_recipe(args.recipe)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../poky/bitbake/lib/bb/tinfoil.py", line 633, in parse_recipe
    fn = self.get_recipe_file(pn)
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../poky/bitbake/lib/bb/tinfoil.py", line 550, in get_recipe_file
    raise bb.providers.NoProvider('Unable to find any recipe file matching "%s"' % pn)
bb.providers.NoProvider: Unable to find any recipe file matching "aaa"

Signed-off-by: Talel BELHAJSALEM <bhstalel@gmail.com>
---
 bitbake/bin/bitbake-getvar | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/bitbake/bin/bitbake-getvar b/bitbake/bin/bitbake-getvar
index 20c0b696f7..a97fdfa719 100755
--- a/bitbake/bin/bitbake-getvar
+++ b/bitbake/bin/bitbake-getvar
@@ -16,6 +16,7 @@  bindir = os.path.dirname(__file__)
 topdir = os.path.dirname(bindir)
 sys.path[0:0] = [os.path.join(topdir, 'lib')]
 
+import bb.providers
 import bb.tinfoil
 
 if __name__ == "__main__":
@@ -40,7 +41,10 @@  if __name__ == "__main__":
     with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not quiet) as tinfoil:
         if args.recipe:
             tinfoil.prepare(quiet=3 if quiet else 2)
-            d = tinfoil.parse_recipe(args.recipe)
+            try:
+                d = tinfoil.parse_recipe(args.recipe)
+            except bb.providers.NoProvider as e:
+                sys.exit(f"{e}")
         else:
             tinfoil.prepare(quiet=2, config_only=True)
             # Expand keys and run anonymous functions to get identical result to