mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-19 04:21:17 +00:00
shh: handle backspaces in serial output
This commit is contained in:
parent
f063726cc3
commit
3247b63cb9
@ -196,7 +196,9 @@ class SshShell(object):
|
|||||||
if index == 0:
|
if index == 0:
|
||||||
self.conn.sendline(self.password)
|
self.conn.sendline(self.password)
|
||||||
timed_out = self._wait_for_prompt(timeout)
|
timed_out = self._wait_for_prompt(timeout)
|
||||||
output = re.sub(r'.*?{}'.format(re.escape(command)), '', self.conn.before, 1).strip()
|
output = re.sub(r' \r([^\n])', r'\1', self.conn.before)
|
||||||
|
output = process_backspaces(output)
|
||||||
|
output = re.sub(r'.*?{}'.format(re.escape(command)), '', output, 1).strip()
|
||||||
else:
|
else:
|
||||||
if log:
|
if log:
|
||||||
logger.debug(command)
|
logger.debug(command)
|
||||||
@ -205,6 +207,7 @@ class SshShell(object):
|
|||||||
# the regex removes line breaks potential introduced when writing
|
# the regex removes line breaks potential introduced when writing
|
||||||
# command to shell.
|
# command to shell.
|
||||||
output = re.sub(r' \r([^\n])', r'\1', self.conn.before)
|
output = re.sub(r' \r([^\n])', r'\1', self.conn.before)
|
||||||
|
output = process_backspaces(output)
|
||||||
command_index = output.find(command)
|
command_index = output.find(command)
|
||||||
output = output[command_index + len(command):].strip()
|
output = output[command_index + len(command):].strip()
|
||||||
if timed_out:
|
if timed_out:
|
||||||
@ -258,3 +261,13 @@ def _check_env():
|
|||||||
if not (ssh and scp):
|
if not (ssh and scp):
|
||||||
raise HostError('OpenSSH must be installed on the host.')
|
raise HostError('OpenSSH must be installed on the host.')
|
||||||
|
|
||||||
|
|
||||||
|
def process_backspaces(text):
|
||||||
|
chars = []
|
||||||
|
for c in text:
|
||||||
|
if c == chr(8) and chars: # backspace
|
||||||
|
chars.pop()
|
||||||
|
else:
|
||||||
|
chars.append(c)
|
||||||
|
return ''.join(chars)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user