1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-05 18:30:50 +01:00

connection: Add ParamikoBackgroundCommand.cmd attr for diagnostic

Add a "cmd" attribute for better exception messages.
This commit is contained in:
Douglas Raillard 2021-08-18 14:09:38 +01:00 committed by Marc Bonnici
parent e231cb0849
commit ad5a97afcc
2 changed files with 4 additions and 1 deletions

View File

@ -241,7 +241,7 @@ class ParamikoBackgroundCommand(BackgroundCommand):
"""
:mod:`paramiko`-based background command.
"""
def __init__(self, conn, chan, pid, as_root, stdin, stdout, stderr, redirect_thread):
def __init__(self, conn, chan, pid, as_root, cmd, stdin, stdout, stderr, redirect_thread):
self.chan = chan
self.as_root = as_root
self.conn = conn
@ -250,6 +250,7 @@ class ParamikoBackgroundCommand(BackgroundCommand):
self._stdout = stdout
self._stderr = stderr
self.redirect_thread = redirect_thread
self.cmd = cmd
def send_signal(self, sig):
# If the command has already completed, we don't want to send a signal

View File

@ -591,6 +591,7 @@ class SshConnection(SshConnectionBase):
return bg_cmd
def _background(self, command, stdout, stderr, as_root):
orig_command = command
stdout, stderr, command = redirect_streams(stdout, stderr, command)
command = "printf '%s\n' $$; exec sh -c {}".format(quote(command))
@ -708,6 +709,7 @@ class SshConnection(SshConnectionBase):
stdout=out_streams['stdout'][0],
stderr=out_streams['stderr'][0],
redirect_thread=redirect_thread,
cmd=orig_command,
)
def _close(self):