lib.Result: Fill "cmd" ctor parameter

Commands executed by ExecContext and its derived classes don't
populate the "cmd" parameter of "Result"'s constructor. Fixing that
makes for nicer error messages.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-13 04:43:34 +02:00
commit 048726a1aa
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
5 changed files with 66 additions and 54 deletions

View file

@ -83,7 +83,7 @@ class Local(Base):
# PTY merges stdout/stderr
stdout = b''.join(stdout_chunks) if stdout_chunks else None
return Result(stdout, None, exit_code)
return Result(stdout, None, exit_code, cmd = cmd)
# -- non-interactive mode
@ -149,7 +149,7 @@ class Local(Base):
stdout = b''.join(stdout_parts) if stdout_parts else None
stderr = b''.join(stderr_parts) if stderr_parts else None
return Result(stdout, stderr, exit_code)
return Result(stdout, stderr, exit_code, cmd = cmd)
finally:
if cwd is not None:

View file

@ -273,7 +273,7 @@ class AsyncSSH(Base):
)
stdout = b''.join(stdout_parts) if stdout_parts else None
return Result(stdout, None, exit_code)
return Result(stdout, None, exit_code, cmd = cmd)
finally:
if stdin_reader_installed:
@ -353,7 +353,7 @@ class AsyncSSH(Base):
exit_code = completed.returncode if completed.returncode is not None else -1
stdout = b''.join(stdout_parts) if stdout_parts else None
return Result(stdout, None, exit_code)
return Result(stdout, None, exit_code, cmd = cmd)
async def _run_ssh(
self,
@ -446,7 +446,7 @@ class AsyncSSH(Base):
completed.returncode if completed.returncode is not None else -1
)
return Result(stdout, stderr, exit_code)
return Result(stdout, stderr, exit_code, cmd = cmd)
except Exception as e:
log(ERR, f'Failed to run command {" ".join(cmd)} ({e})')

View file

@ -84,4 +84,4 @@ class Paramiko(Base):
if cmd_input is not None:
stdin.write(cmd_input)
exit_status = stdout.channel.recv_exit_status()
return Result(stdout.read(), stderr.read(), exit_status)
return Result(stdout.read(), stderr.read(), exit_status, cmd = cmd)