avocado.core.exceptions: Modifications to CmdError for serialization

In order to serialize the CmdError class, we need to
allow passing None command and CmdResult objects to
the class constructor.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 805abde1
......@@ -106,15 +106,18 @@ class TestWarn(TestBaseException):
class CmdError(Exception):
def __init__(self, command, result):
def __init__(self, command=None, result=None):
self.command = command
self.result = result
def __str__(self):
if self.result.exit_status is None:
msg = "Command '%s' failed and is not responding to signals"
msg %= self.command
if self.result is not None:
if self.result.exit_status is None:
msg = "Command '%s' failed and is not responding to signals"
msg %= self.command
else:
msg = "Command '%s' failed (rc=%d)"
msg %= (self.command, self.result.exit_status)
return msg
else:
msg = "Command '%s' failed (rc=%d)"
msg %= (self.command, self.result.exit_status)
return msg
return "CmdError"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册