aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/ssh.py41
1 files changed, 24 insertions, 17 deletions
diff --git a/resources/libraries/python/ssh.py b/resources/libraries/python/ssh.py
index 287ad31d65..8acb54b382 100644
--- a/resources/libraries/python/ssh.py
+++ b/resources/libraries/python/ssh.py
@@ -21,7 +21,6 @@ import paramiko
from paramiko import RSAKey
from paramiko.ssh_exception import SSHException
from scp import SCPClient
-from interruptingcow import timeout as icTimeout
from robot.api import logger
from robot.utils.asserts import assert_equal
@@ -213,19 +212,23 @@ class SSH(object):
chan.get_pty()
chan.invoke_shell()
chan.settimeout(int(time_out))
+ chan.set_combine_stderr(True)
buf = ''
- try:
- with icTimeout(time_out, exception=RuntimeError):
- while not buf.endswith(':~$ '):
- if chan.recv_ready():
- buf = chan.recv(4096)
- except RuntimeError:
- raise Exception('Open interactive terminal timeout.')
+ while not buf.endswith(':~$ '):
+ try:
+ chunk = chan.recv(self.__MAX_RECV_BUF)
+ if not chunk:
+ break
+ buf += chunk
+ if chan.exit_status_ready():
+ logger.error('Channel exit status ready')
+ break
+ except socket.timeout:
+ raise Exception('Socket timeout: {0}'.format(buf))
return chan
- @staticmethod
- def interactive_terminal_exec_command(chan, cmd, prompt,
+ def interactive_terminal_exec_command(self, chan, cmd, prompt,
time_out=30):
"""Execute command on interactive terminal.
@@ -247,13 +250,17 @@ class SSH(object):
"""
chan.sendall('{c}\n'.format(c=cmd))
buf = ''
- try:
- with icTimeout(time_out, exception=RuntimeError):
- while not buf.endswith(prompt):
- if chan.recv_ready():
- buf += chan.recv(4096)
- except RuntimeError:
- raise Exception("Exec '{c}' timeout.".format(c=cmd))
+ while not buf.endswith(prompt):
+ try:
+ chunk = chan.recv(self.__MAX_RECV_BUF)
+ if not chunk:
+ break
+ buf += chunk
+ if chan.exit_status_ready():
+ logger.error('Channel exit status ready')
+ break
+ except socket.timeout:
+ raise Exception('Socket timeout: {0}'.format(buf))
tmp = buf.replace(cmd.replace('\n', ''), '')
return tmp.replace(prompt, '')