1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

wlauto/utils/ssh.py: Fix set terminal window size

Ensure that the terminal window size is set to 500x200, if not long
commands (prompt + command > 80 chars) will fail because the pexpect
search to match the command string in order to get the result and the
command is wrapped to first 80 chars.

For example, when check a file and executes:

...
if [ -f '/sys/kernel/debug/sched_features' ]; then echo 1; else echo 0; fi
...
File
\"/usr/local/lib/python2.7/dist-packages/wlauto/common/linux/device.py\",
line 228, in get_properties
if self.is_file(propfile):
File
\"/usr/local/lib/python2.7/dist-packages/wlauto/common/linux/device.py\",
line 215, in is_file
return boolean(output.split()[-1])  # pylint: disable=maybe-no-member

IndexError(list index out of range)
...

In order to fix this scenario enables checkwinsize in the shell and use
stty to set the new terminal window size.

Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
This commit is contained in:
Aníbal Limón 2018-04-10 12:28:26 -05:00 committed by Marc Bonnici
parent ea22bc062e
commit 1b0799bcc5

View File

@ -66,9 +66,15 @@ def ssh_get_shell(host, username, password=None, keyfile=None, port=None, timeou
raise DeviceError(message.format(host)) raise DeviceError(message.format(host))
time.sleep(5) time.sleep(5)
conn.sendline('shopt -s checkwinsize')
conn.prompt()
conn.setwinsize(500,200) conn.setwinsize(500,200)
conn.sendline('') conn.sendline('')
conn.prompt() conn.prompt()
conn.sendline('stty rows 500')
conn.prompt()
conn.sendline('stty cols 200')
conn.prompt()
conn.setecho(False) conn.setecho(False)
return conn return conn