mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
ssh: Fix command line echoing
Command line echoing was disabled, but that disabling did not take effect. Another part of devlib was still expecting command lines to be echoed. That is fixed by disabling echoing when creating pxssh connection, and removing the code that expected the line to be echoed.
This commit is contained in:
parent
22f2c8b663
commit
2e81a72b39
@ -63,7 +63,7 @@ def ssh_get_shell(host, username, password=None, keyfile=None, port=None, timeou
|
|||||||
raise ValueError('keyfile may not be used with a telnet connection.')
|
raise ValueError('keyfile may not be used with a telnet connection.')
|
||||||
conn = TelnetPxssh(original_prompt=original_prompt)
|
conn = TelnetPxssh(original_prompt=original_prompt)
|
||||||
else: # ssh
|
else: # ssh
|
||||||
conn = pxssh.pxssh()
|
conn = pxssh.pxssh(echo=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if keyfile:
|
if keyfile:
|
||||||
@ -278,15 +278,11 @@ class SshConnection(object):
|
|||||||
logger.debug(command)
|
logger.debug(command)
|
||||||
self._sendline(command)
|
self._sendline(command)
|
||||||
timed_out = self._wait_for_prompt(timeout)
|
timed_out = self._wait_for_prompt(timeout)
|
||||||
# the regex removes line breaks potential introduced when writing
|
|
||||||
# command to shell.
|
|
||||||
if sys.version_info[0] == 3:
|
if sys.version_info[0] == 3:
|
||||||
output = process_backspaces(self.conn.before.decode(sys.stdout.encoding or 'utf-8', 'replace'))
|
output = process_backspaces(self.conn.before.decode(sys.stdout.encoding or 'utf-8', 'replace'))
|
||||||
else:
|
else:
|
||||||
output = process_backspaces(self.conn.before)
|
output = process_backspaces(self.conn.before)
|
||||||
output = re.sub(r'\r([^\n])', r'\1', output)
|
|
||||||
if '\r\n' in output: # strip the echoed command
|
|
||||||
output = output.split('\r\n', 1)[1]
|
|
||||||
if timed_out:
|
if timed_out:
|
||||||
self.cancel_running_command()
|
self.cancel_running_command()
|
||||||
raise TimeoutError(command, output)
|
raise TimeoutError(command, output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user