bitbake-devel.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] build: Match markup to real function name
@ 2021-09-10  9:15 Richard Purdie
  2021-09-10  9:15 ` [PATCH 2/3] build: Handle SystemExit in python tasks correctly Richard Purdie
  2021-09-10  9:15 ` [PATCH 3/3] process: Don't include logs in error message if piping them Richard Purdie
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Purdie @ 2021-09-10  9:15 UTC (permalink / raw)
  To: bitbake-devel

The point of the injected text is to identify where the function comes from. Using
the correct function name would therefore be better.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/build.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bb/build.py b/lib/bb/build.py
index 6ce8f1e6d3..ab3344c460 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -295,8 +295,8 @@ def exec_func_python(func, d, runfile, cwd=None):
         lineno = int(d.getVarFlag(func, "lineno", False))
         bb.methodpool.insert_method(func, text, fn, lineno - 1)
 
-        comp = utils.better_compile(code, func, "exec_python_func() autogenerated")
-        utils.better_exec(comp, {"d": d}, code, "exec_python_func() autogenerated")
+        comp = utils.better_compile(code, func, "exec_func_python() autogenerated")
+        utils.better_exec(comp, {"d": d}, code, "exec_func_python() autogenerated")
     finally:
         bb.debug(2, "Python function %s finished" % func)
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] build: Handle SystemExit in python tasks correctly
  2021-09-10  9:15 [PATCH 1/3] build: Match markup to real function name Richard Purdie
@ 2021-09-10  9:15 ` Richard Purdie
  2021-09-10  9:15 ` [PATCH 3/3] process: Don't include logs in error message if piping them Richard Purdie
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2021-09-10  9:15 UTC (permalink / raw)
  To: bitbake-devel

If a python task fails with sys.exit(), we currently see no TaskFailed event.
The high level code does detect the exit code and fail the task but it can
leave the UI inconsistent with log output.

Fix this be intercepting SystemExit explicitly. This makes python
task failures consistent with shell task failures.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/build.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/bb/build.py b/lib/bb/build.py
index ab3344c460..9862e8878e 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -694,7 +694,7 @@ def _exec_task(fn, task, d, quieterr):
         except bb.BBHandledException:
             event.fire(TaskFailed(task, fn, logfn, localdata, True), localdata)
             return 1
-        except Exception as exc:
+        except (Exception, SystemExit) as exc:
             if quieterr:
                 event.fire(TaskFailedSilent(task, fn, logfn, localdata), localdata)
             else:
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] process: Don't include logs in error message if piping them
  2021-09-10  9:15 [PATCH 1/3] build: Match markup to real function name Richard Purdie
  2021-09-10  9:15 ` [PATCH 2/3] build: Handle SystemExit in python tasks correctly Richard Purdie
@ 2021-09-10  9:15 ` Richard Purdie
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2021-09-10  9:15 UTC (permalink / raw)
  To: bitbake-devel

If the caller is piping the logs, they likely don't want them in the error exception
as well. This removes duplicate output from the build output allowing the UI level
controls on whether to show logs to work correctly.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/process.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/bb/process.py b/lib/bb/process.py
index 7c3995cce5..d5a1775fce 100644
--- a/lib/bb/process.py
+++ b/lib/bb/process.py
@@ -181,5 +181,8 @@ def run(cmd, input=None, log=None, extrafiles=None, **options):
             stderr = stderr.decode("utf-8")
 
     if pipe.returncode != 0:
+        if log:
+            # Don't duplicate the output in the exception if logging it
+            raise ExecutionError(cmd, pipe.returncode, None, None)
         raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
     return stdout, stderr
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-10  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10  9:15 [PATCH 1/3] build: Match markup to real function name Richard Purdie
2021-09-10  9:15 ` [PATCH 2/3] build: Handle SystemExit in python tasks correctly Richard Purdie
2021-09-10  9:15 ` [PATCH 3/3] process: Don't include logs in error message if piping them Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).