On Wed, Mar 16, 2016 at 10:29:13AM +0100, Jan Tluka wrote:
ExecCmdFail exception is thrown if a command returns with non-zero
returncode. When this happens only stderr is saved in the exception.
User might want to work with both the stdout and stderr.
This patch saves stdout data along with stderr in this case.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Common/ExecCmd.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lnst/Common/ExecCmd.py b/lnst/Common/ExecCmd.py
index d6c92c6..d432c2c 100644
--- a/lnst/Common/ExecCmd.py
+++ b/lnst/Common/ExecCmd.py
@@ -17,10 +17,12 @@ class ExecCmdFail(Exception):
_cmd = None
_retval = None
_stderr = None
+ _stdout = None
_report_stderr = None
- def __init__(self, cmd=None, retval=None, err="", report_stderr=False):
- self._stderr = err
+ def __init__(self, cmd=None, retval=None, outs=["", ""],
report_stderr=False):
+ self._stdout = outs[0]
+ self._stderr = outs[1]
self._retval = retval
self._report_stderr = report_stderr
@@ -30,6 +32,9 @@ class ExecCmdFail(Exception):
def get_stderr(self):
return self._stderr
+ def get_stdout(self):
+ return self._stdout
+
def __str__(self):
retval = ""
stderr = ""
Could we maybe include the stdout in the __str__ method of the
exception? I'm not sure if it's used anywhere, but it seems like a
reasonable idea if we have it available...
otherwise ack to set:
Acked-by: Ondrej Lichtner <olichtne(a)redhat.com>