command: Ensure exceptions inheriting from BBHandledException are visible
PATCH 1/2 command: Ensure exceptions inheriting from BBHandledException are visible
Previous changes allowed BBHandledException to be detected but not exceptions which inherit from it. Fix this. The code really needs totally reworking to preserve the exceptions.
[YOCTO #14054]
--- lib/bb/command.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/bb/command.py +5 -1
@@ -81,8 +81,12 @@ class Command: result = command_method(self, commandline) except CommandError as exc: return None, exc.args[0] - except (Exception, SystemExit): + except (Exception, SystemExit) as exc: import traceback + if isinstance(exc, bb.BBHandledException): + # We need to start returning real exceptions here. Until we do, we can't + # tell if an exception is an instance of bb.BBHandledException + return None, "bb.BBHandledException()\n" + traceback.format_exc() return None, traceback.format_exc() else: return result, None
Signature · 1 line
2.25.1
PATCH 2/2 tinfoil: When sending commands we need to process events
The server may be displaying useful information for the user through log messages so we should display anything that has been sent. Its either this or expecting every UI to implement this code around every command call which isn't good API.
[YOCTO #14054]
--- lib/bb/tinfoil.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
lib/bb/tinfoil.py +10 -1
@@ -461,7 +461,16 @@ class Tinfoil: commandline = [command] if params: commandline.extend(params) - result = self.server_connection.connection.runCommand(commandline) + try: + result = self.server_connection.connection.runCommand(commandline) + finally: + while True: + event = self.wait_event() + if not event: + break + if isinstance(event, logging.LogRecord): + if event.taskpid == 0 or event.levelno > logging.INFO: + self.logger.handle(event) if result[1]: raise TinfoilCommandFailed(result[1]) return result[0]
Signature · 1 line
2.25.1
Re: [bitbake-devel] [PATCH 2/2] tinfoil: When sending commands we need to process events
Hi Richard
Quoted 24 lines · On Saturday, 10 October 2020 05:51:24 NZDT Richard Purdie wrote:
The server may be displaying useful information for the user through log messages so we should display anything that has been sent. Its either this or expecting every UI to implement this code around every command call which isn't good API.
[YOCTO #14054]
Signed-off-by Richard Purdie <[email protected]>--- lib/bb/tinfoil.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)lib/bb/tinfoil.py +2
-1@@ -461,7 +461,16 @@ class Tinfoil: commandline = [command] if params: commandline.extend(params) - result = self.server_connection.connection.runCommand(commandline) + try: + result =
self.server_connection.connection.runCommand(commandline)+ finally:
lib/bb/tinfoil.py class Tinfoil: · line 476
Quoted 10 lines
lib/bb/tinfoil.py +7
-0+ while True: + event = self.wait_event() + if not event: + break + if isinstance(event, logging.LogRecord): + if event.taskpid == 0 or event.levelno > logging.INFO: + self.logger.handle(event) if result[1]: raise TinfoilCommandFailed(result[1]) return result[0]
Won't this eat events that aren't LogRecords? I understand the intention, and am happy for this to be the default behaviour, but we have several callers of run_command() which are expecting to receive events by themselves using wait_event(). Should we perhaps add a parameter to disable this and specify that in those callers? I'm happy to cook up that patch if so.
Cheers
Paul
Re: [bitbake-devel] [PATCH 2/2] tinfoil: When sending commands we need to process events
Quoted 41 lines · Paul Eggleton
Hi Richard
Quoted 27 lines · On Saturday, 10 October 2020 05:51:24 NZDT Richard Purdie wrote:
The server may be displaying useful information for the user through log messages so we should display anything that has been sent. Its either this or expecting every UI to implement this code around every command call which isn't good API.
[YOCTO #14054]
Signed-off-by Richard Purdie <[email protected]>--- lib/bb/tinfoil.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)lib/bb/tinfoil.py +0
-0@@ -461,7 +461,16 @@ class Tinfoil: commandlineQuoted 3 lines
Cheers> Paul>
= [command]
if params:
commandline.extend(params)lib/bb/tinfoil.py +2
-1- result = self.server_connection.connection.runCommand(commandline) + try: + result =
self.server_connection.connection.runCommand(commandline)+ finally:lib/bb/tinfoil.py class Tinfoil: · line 476
Quoted 10 lines
lib/bb/tinfoil.py +7
-0+ while True: + event = self.wait_event() + if not event: + break + if isinstance(event, logging.LogRecord): + if event.taskpid == 0 or event.levelno > logging.INFO: + self.logger.handle(event) if result[1]: raise TinfoilCommandFailed(result[1]) return result[0]
Quoted 5 lines
Won't this eat events that aren't LogRecords? I understand the intention, and am happy for this to be the default behaviour, but we have several callers of
run_command()which are expecting to receive events by themselves usingwait_event(). Should we perhaps add a parameter to disable this and specify that in those callers? I'm happy to cook up that patch if so.
Yes, you're right, we do need to something different here. I was thinking this didn't clear the queue for some reason but it obviously does. Making it a parameter depending on whether the caller is handling this or not would be best as you say.
I was trying to avoid having to change all the callers but I think that is inevitable.
Cheers,
Richard