From 4d9b95cde48fe1b9abf70a5c7c2edcdb3199776d Mon Sep 17 00:00:00 2001 From: Tibor Frank Date: Mon, 30 Jan 2017 11:38:17 +0100 Subject: CSIT-514: Kill Qemu when it does not respond Change-Id: Id13c7fd51e693a273637c80cb35a159434be4826 Signed-off-by: Tibor Frank --- resources/libraries/python/ssh.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'resources/libraries/python/ssh.py') diff --git a/resources/libraries/python/ssh.py b/resources/libraries/python/ssh.py index 90ac0be2dc..3a2c1b661a 100644 --- a/resources/libraries/python/ssh.py +++ b/resources/libraries/python/ssh.py @@ -29,6 +29,11 @@ __all__ = ["exec_cmd", "exec_cmd_no_error"] # TODO: load priv key +class SSHTimeout(Exception): + """This exception is raised when a timeout occurs.""" + pass + + class SSH(object): """Contains methods for managing and using SSH connections.""" @@ -118,7 +123,7 @@ class SSH(object): :type timeout: int :return return_code, stdout, stderr :rtype: tuple(int, str, str) - :raise socket.timeout: If command is not finished in timeout time. + :raise SSHTimeout: If command is not finished in timeout time. """ start = time() stdout = StringIO.StringIO() @@ -144,7 +149,7 @@ class SSH(object): stderr.write(chan.recv_stderr(self.__MAX_RECV_BUF)) if time() - start > timeout: - raise socket.timeout( + raise SSHTimeout( 'Timeout exception.\n' 'Current contents of stdout buffer: {0}\n' 'Current contents of stderr buffer: {1}\n' -- cgit 1.2.3-korg