Skip to contentSkip to conversation

[2.0][PATCH 1/2] bitbake-getvar: Make --quiet work with --recipe

PATCH Martin Jansa 1 participant 2 messages Nov 3, 2023

lore
Share & tools
lore
#0 lore raw

From: Peter Kjellerstedt <[email protected]>

Initializing Tinfoil with setup_logging = False only has an effect when recipe parsing is not needed. To make it work regardless of if --recipe is used, manipulate the quiet parameter to Tinfoil.prepare() instead.

---
 bin/bitbake-getvar | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
bin/bitbake-getvar +3 -2
index 4a9eb4f31..13a317e1d 100755
@@ -36,9 +36,10 @@ if __name__ == "__main__":
         print("--flag only makes sense with --value")
         sys.exit(1)
 
-    with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not args.quiet) as tinfoil:
+    quiet = args.quiet
+    with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not quiet) as tinfoil:
         if args.recipe:
-            tinfoil.prepare(quiet=2)
+            tinfoil.prepare(quiet=3 if quiet else 2)
             d = tinfoil.parse_recipe(args.recipe)
         else:
             tinfoil.prepare(quiet=2, config_only=True)
Signature · 1 line
2.42.0
#1 lore raw

[2.0][PATCH 2/2] tinfoil: Do not fail when logging is disabled and full config is used

From: Peter Kjellerstedt <[email protected]>

If Tinfoil is initialized with setup_logging = False and Tinfoil.prepare() is called with config_only = False, then it fails because self.localhandlers is only initialized when setup_logging = True.

This is seen with, e.g., bitbake-getvar -q -r busybox MACHINE:

Traceback (most recent call last):

    File ".../bitbake/bin/bitbake-getvar", line 41, in <module>
      tinfoil.prepare(quiet=2)
    File ".../bitbake/lib/bb/tinfoil.py", line 390, in prepare
      for handler in self.localhandlers:

AttributeError: 'Tinfoil' object has no attribute 'localhandlers'. Did you mean: 'oldhandlers'?

---
 lib/bb/tinfoil.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/tinfoil.py +1 -1
index e68a3b879..fa29b930c 100644
@@ -324,11 +324,11 @@ class Tinfoil:
         self.recipes_parsed = False
         self.quiet = 0
         self.oldhandlers = self.logger.handlers[:]
+        self.localhandlers = []
         if setup_logging:
             # This is the *client-side* logger, nothing to do with
             # logging messages from the server
             bb.msg.logger_create('BitBake', output)
-            self.localhandlers = []
             for handler in self.logger.handlers:
                 if handler not in self.oldhandlers:
                     self.localhandlers.append(handler)
Signature · 1 line
2.42.0