u_boot_pylib: command: Convert output before raising exception

Call to_output() before raising CommandExc so that callers catching
the exception get string output rather than bytes. This avoids the need
for callers to handle bytes decoding themselves.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2026-01-02 12:03:42 -07:00
parent 6cff0c8a55
commit ca9c339b24

View File

@@ -136,9 +136,10 @@ def run_pipe(pipe_list, infile=None, outfile=None, capture=False,
if result.stdout and oneline:
result.output = result.stdout.rstrip(b'\r\n')
result.return_code = last_pipe.wait()
result = result.to_output(binary)
if raise_on_error and result.return_code:
raise CommandExc(f"Error running '{user_pipestr}'", result)
return result.to_output(binary)
return result
def output(*cmd, **kwargs):