Skip to content

Commit

Permalink
[flashing scripts] Log errors from subprocesses (#15593)
Browse files Browse the repository at this point in the history
#### Problem

It's difficult to troubleshoot errors frome external commands
run by the flashing scripts, because their output is captured
and not reported.

#### Change overview

Log command stdout and stderr in case of failure.

#### Testing

Manual run.
  • Loading branch information
kpschoedel authored and pull[bot] committed Feb 1, 2024
1 parent c53d69d commit 3a55391
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/flashing/firmware_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,15 @@ def run_tool(self,
capture_output=True)
else:
result = self
self.err = subprocess.call(command)
self.error = subprocess.check_call(command)
except subprocess.CalledProcessError as exception:
self.err = exception.returncode
if capture_output:
self.log(fail_level, '--- stdout ---')
self.log(fail_level, exception.stdout)
self.log(fail_level, '--- stderr ---')
self.log(fail_level, exception.stderr)
self.log(fail_level, '---')
except FileNotFoundError as exception:
self.err = exception.errno
if self.err == errno.ENOENT:
Expand Down

0 comments on commit 3a55391

Please sign in to comment.