Skip to contentSkip to conversation

bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them

PATCH In review Humberto Ibarra 2 participants 2 messages May 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them

If an invalid layer is added to bblayers.conf, the parsing of said file ends with a trace and an "Unable to parse" exception. This is not the ideal output, especially considering that we know exactly why this is failing.

This patch checks if a layer conf file exists before trying to parse it. If it does not, a clear and more concise message is send to the user. Otherwise, the parsing continues.

[Yocto #9506]

---
 bitbake/lib/bb/cookerdata.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
bitbake/lib/bb/cookerdata.py +7 -3
index 50259a9..a1b0457 100644
@@ -178,9 +178,13 @@ def catch_parse_error(func):
         try:
             return func(fn, *args)
         except IOError as exc:
-            import traceback
-            parselog.critical(traceback.format_exc())
-            parselog.critical("Unable to parse %s: %s" % (fn, exc))
+            import errno
+            if exc.errno == errno.ENOENT:
+                parselog.critical("Unable to find the configuration file: %s" % fn)
+            else:
+                import traceback
+                parselog.critical(traceback.format_exc())
+                parselog.critical("Unable to parse %s: %s" % (fn, exc))
             sys.exit(1)
         except bb.data_smart.ExpansionError as exc:
             import traceback
Signature · 1 line
2.4.11
#1 lore raw
Quoted 9 lines · Humberto Ibarra

If an invalid layer is added to bblayers.conf, the parsing of said file ends with a trace and an "Unable to parse" exception. This is not the ideal output, especially considering that we know exactly why this is failing.

This patch checks if a layer conf file exists before trying to parse it. If it does not, a clear and more concise message is send to the user. Otherwise, the parsing continues.

This commit message no longer accurately describes the change :)

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics