aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/ssh.py
diff options
context:
space:
mode:
authorMatej Klotton <mklotton@cisco.com>2016-03-03 17:49:13 +0100
committerGerrit Code Review <gerrit@fd.io>2016-03-11 12:22:05 +0000
commit05eba892c7d2a778e78a950966fb1a6e0d68aa60 (patch)
tree70deac23c37148021dce43b8277ee079b6ea0e81 /resources/libraries/python/ssh.py
parent5fbbffd70f3b03b1778d31173065d86bfcc9a975 (diff)
Update VPP version downloaded from Nexus.
Change-Id: Iae2ee6d576347262d9f3f9a9e9b9cc65dbc5bf5e Signed-off-by: Matej Klotton <mklotton@cisco.com>
Diffstat (limited to 'resources/libraries/python/ssh.py')
-rw-r--r--resources/libraries/python/ssh.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/resources/libraries/python/ssh.py b/resources/libraries/python/ssh.py
index a2bb9b1dc4..2de6f4a36e 100644
--- a/resources/libraries/python/ssh.py
+++ b/resources/libraries/python/ssh.py
@@ -18,6 +18,7 @@ from time import time
from robot.api import logger
from interruptingcow import timeout
from robot.utils.asserts import assert_equal, assert_not_equal
+from socket import timeout as socket_timeout
__all__ = ["exec_cmd", "exec_cmd_no_error"]
@@ -72,7 +73,7 @@ class SSH(object):
Returns (return_code, stdout, stderr).
"""
logger.trace('exec_command on {0}: {1}'
- .format(self._ssh.get_transport().getpeername(), cmd))
+ .format(self._ssh.get_transport().getpeername(), cmd))
start = time()
chan = self._ssh.get_transport().open_session()
if timeout is not None:
@@ -84,22 +85,33 @@ class SSH(object):
stdout = ""
while True:
- buf = chan.recv(self.__MAX_RECV_BUF)
- stdout += buf
- if not buf:
+ try:
+ buf = chan.recv(self.__MAX_RECV_BUF)
+ stdout += buf
+ if not buf:
+ break
+ except socket_timeout:
+ logger.trace('Channels stdout timeout occurred')
break
stderr = ""
while True:
- buf = chan.recv_stderr(self.__MAX_RECV_BUF)
- stderr += buf
- if not buf:
+ try:
+ buf = chan.recv_stderr(self.__MAX_RECV_BUF)
+ stderr += buf
+ if not buf:
+ break
+ except socket_timeout:
+ logger.trace('Channels stderr timeout occurred')
break
return_code = chan.recv_exit_status()
logger.trace('chan_recv/_stderr took {} seconds'.format(time()-end))
- return (return_code, stdout, stderr)
+ logger.trace('return RC {}'.format(return_code))
+ logger.trace('return STDOUT {}'.format(stdout))
+ logger.trace('return STDERR {}'.format(stderr))
+ return return_code, stdout, stderr
def exec_command_sudo(self, cmd, cmd_input=None, timeout=10):
"""Execute SSH command with sudo on a new channel on the connected Node.