User is not able to get the stdout or stderr if a command he runs fails and he specified save_output command run option. This patch saves the command outputs from ExecCmdFail exception in res_data if requested.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Common/NetTestCommand.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py index 409076b..774c26e 100644 --- a/lnst/Common/NetTestCommand.py +++ b/lnst/Common/NetTestCommand.py @@ -413,12 +413,16 @@ class NetTestCommandExec(NetTestCommandGeneric): if self._save_output: res_data = { "stdout": stdout, "stderr": stderr } self.set_pass(res_data) - except ExecCmdFail: + except ExecCmdFail as e: + res_data = None + if self._save_output: + res_data = { "stdout": e.get_stdout(), + "stderr": e.get_stderr() } if "bg_id" in self._command: logging.info("Command probably intentionally killed. Passing.") - self.set_pass() + self.set_pass(res_data) else: - self.set_fail() + self.set_fail(res_data)
def _format_cmd_res_header(self): cmd_type = self._command["type"]