1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-03-04 01:07:51 +00:00

Merge pull request #158 from bjackman/ssh-improve-errors

Improve SshConnection.push errors
This commit is contained in:
marcbonnici 2017-08-09 16:18:46 +01:00 committed by GitHub
commit 22b6514c35

View File

@ -284,16 +284,18 @@ class SshConnection(object):
port_string = '-P {}'.format(self.port) if (self.port and self.port != 22) else ''
keyfile_string = '-i {}'.format(self.keyfile) if self.keyfile else ''
command = '{} -r {} {} {} {}'.format(scp, keyfile_string, port_string, source, dest)
pass_string = ''
command_redacted = command
logger.debug(command)
if self.password:
command = _give_password(self.password, command)
command_redacted = command.replace(self.password, '<redacted>')
try:
check_output(command, timeout=timeout, shell=True)
except subprocess.CalledProcessError as e:
raise subprocess.CalledProcessError(e.returncode, e.cmd.replace(pass_string, ''), e.output)
raise HostError("Failed to copy file with '{}'. Output:\n{}".format(
command_redacted, e.output))
except TimeoutError as e:
raise TimeoutError(e.command.replace(pass_string, ''), e.output)
raise TimeoutError(command_redacted, e.output)
class TelnetConnection(SshConnection):