This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch 2.8.x
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit b6e33ff0a6a9dec5331a58ecb49124b47b042f2c
Author: Tomaz Muraus <[email protected]>
AuthorDate: Thu Apr 2 15:39:00 2020 +0200

    Add new stdout and stderr attribute to SSHCommandTimeoutError class.
    
    Those two attributes contain stdout and stderr produced so far before
    encoutering a timeout.
---
 libcloud/compute/ssh.py   | 17 ++++++++++++-----
 libcloud/compute/types.py |  1 +
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/libcloud/compute/ssh.py b/libcloud/compute/ssh.py
index 0c65abf..f4207e5 100644
--- a/libcloud/compute/ssh.py
+++ b/libcloud/compute/ssh.py
@@ -64,10 +64,13 @@ class SSHCommandTimeoutError(Exception):
     """
     Exception which is raised when an SSH command times out.
     """
-    def __init__(self, cmd, timeout):
-        # type: (str, float) -> None
+    def __init__(self, cmd, timeout, stdout=None, stderr=None):
+        # type: (str, float, Optional[str], Optional[str]) -> None
         self.cmd = cmd
         self.timeout = timeout
+        self.stdout = stdout
+        self.stderr = stderr
+
         self.message = 'Command didn\'t finish in %s seconds' % (timeout)
         super(SSHCommandTimeoutError, self).__init__(self.message)
 
@@ -433,7 +436,11 @@ class ParamikoSSHClient(BaseSSHClient):
                 # TODO: Is this the right way to clean up?
                 chan.close()
 
-                raise SSHCommandTimeoutError(cmd=cmd, timeout=timeout)
+                stdout_str = stdout.getvalue()  # type: str
+                stderr_str = stderr.getvalue()  # type: str
+                raise SSHCommandTimeoutError(cmd=cmd, timeout=timeout,
+                                             stdout=stdout_str,
+                                             stderr=stderr_str)
 
             stdout.write(self._consume_stdout(chan).getvalue())
             stderr.write(self._consume_stderr(chan).getvalue())
@@ -451,8 +458,8 @@ class ParamikoSSHClient(BaseSSHClient):
         # Receive the exit status code of the command we ran.
         status = chan.recv_exit_status()  # type: int
 
-        stdout_str = stdout.getvalue()  # type: str
-        stderr_str = stderr.getvalue()  # type: str
+        stdout_str = stdout.getvalue()
+        stderr_str = stderr.getvalue()
 
         extra2 = {'_status': status, '_stdout': stdout_str,
                   '_stderr': stderr_str}
diff --git a/libcloud/compute/types.py b/libcloud/compute/types.py
index 1c4be60..006a1eb 100644
--- a/libcloud/compute/types.py
+++ b/libcloud/compute/types.py
@@ -394,6 +394,7 @@ class DeploymentError(LibcloudError):
     def __init__(self, node, original_exception=None, driver=None):
         self.node = node
         self.value = original_exception
+        self.original_error = original_exception
         self.driver = driver
 
     def __str__(self):

Reply via email to