From 4ea4bc86315a081f8054a874f0e13e5e306dc16f Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Tue, 23 Aug 2016 17:14:45 +0100 Subject: [PATCH] ssh: fixing rasing of CalledProcessErrorWithStderr CalledProcessErrorWithStderr is a subclass of CalledProcessError that also takes stderr output. Both that and normal output must be passed as keyword arguments. They were being passed as keyword arguments inside _scp() of SshConnection, causing cryptic errors to appear. Additionally, "output" was not being properly poped off before invoking super's init. --- wlauto/utils/misc.py | 1 + wlauto/utils/ssh.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wlauto/utils/misc.py b/wlauto/utils/misc.py index 4747c4ba..51829ebe 100644 --- a/wlauto/utils/misc.py +++ b/wlauto/utils/misc.py @@ -85,6 +85,7 @@ class TimeoutError(Exception): class CalledProcessErrorWithStderr(CalledProcessError): def __init__(self, *args, **kwargs): + self.output = kwargs.pop("output") self.error = kwargs.pop("error") super(CalledProcessErrorWithStderr, self).__init__(*args, **kwargs) diff --git a/wlauto/utils/ssh.py b/wlauto/utils/ssh.py index c5bd1777..e62203df 100644 --- a/wlauto/utils/ssh.py +++ b/wlauto/utils/ssh.py @@ -245,7 +245,8 @@ class SshShell(object): except subprocess.CalledProcessError as e: raise CalledProcessErrorWithStderr(e.returncode, e.cmd.replace(pass_string, ''), - e.output, getattr(e, 'error', '')) + output=e.output, + error=getattr(e, 'error', '')) except TimeoutError as e: raise TimeoutError(e.command.replace(pass_string, ''), e.output)