* [PATCH v3] bitbake/lib/bb/cookerdata.py: Improve response when bitbake-layers can't find layer conf file
@ 2016-05-12 19:17 Humberto Ibarra
2016-05-12 22:55 ` Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: Humberto Ibarra @ 2016-05-12 19:17 UTC (permalink / raw)
To: bitbake-devel
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 handles this situation failing with a graceful error message. The
message shows the path to the conf file that couldn't be found.
[Yocto #9506]
Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com>
---
bitbake/lib/bb/cookerdata.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 50259a9..a1b0457 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -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
--
2.4.11
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v3] bitbake/lib/bb/cookerdata.py: Improve response when bitbake-layers can't find layer conf file
2016-05-12 19:17 [PATCH v3] bitbake/lib/bb/cookerdata.py: Improve response when bitbake-layers can't find layer conf file Humberto Ibarra
@ 2016-05-12 22:55 ` Richard Purdie
2016-05-12 23:10 ` Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2016-05-12 22:55 UTC (permalink / raw)
To: Humberto Ibarra, bitbake-devel
On Thu, 2016-05-12 at 14:17 -0500, Humberto Ibarra wrote:
> 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 handles this situation failing with a graceful error
> message. The
> message shows the path to the conf file that couldn't be found.
>
> [Yocto #9506]
>
> Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com>
> ---
> bitbake/lib/bb/cookerdata.py | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/bitbake/lib/bb/cookerdata.py
> b/bitbake/lib/bb/cookerdata.py
> index 50259a9..a1b0457 100644
> --- a/bitbake/lib/bb/cookerdata.py
> +++ b/bitbake/lib/bb/cookerdata.py
> @@ -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
I think I'm not going to take this patch. My concern is that we have a
number of places where we'd have this problem and adding in specific
exception handling in all of them is going to be tricky.
I do agree we need to solve the problem and started to wonder if we
could make the standard exception more useful. I then realised that in
python3, they already did. If I try this under python3, I see:
FileNotFoundError: [Errno 2] file /foo/bar/conf/layer.conf not found
ERROR: Unable to parse /foo/bar/conf/layer.conf: [Errno 2] file /foo/bar/conf/layer.conf not found
So with python3, we get better exceptions for free with no code changes.
Can we therefore say this will be fixed with the move to python3?
It would be good to double check as I just tested this with bitbake and
bitbake-layers hasn't been ported to python3 yet but I'd imagine its
the same.
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] bitbake/lib/bb/cookerdata.py: Improve response when bitbake-layers can't find layer conf file
2016-05-12 22:55 ` Richard Purdie
@ 2016-05-12 23:10 ` Richard Purdie
0 siblings, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2016-05-12 23:10 UTC (permalink / raw)
To: Humberto Ibarra, bitbake-devel
On Thu, 2016-05-12 at 23:55 +0100, Richard Purdie wrote:
> It would be good to double check as I just tested this with bitbake
> and bitbake-layers hasn't been ported to python3 yet but I'd imagine
> its the same.
I just pushed an update to the branch which fixes bitbake-layers under
python3 and confirmed it does show the filename.
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-12 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-12 19:17 [PATCH v3] bitbake/lib/bb/cookerdata.py: Improve response when bitbake-layers can't find layer conf file Humberto Ibarra
2016-05-12 22:55 ` Richard Purdie
2016-05-12 23:10 ` Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.