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,11 +106,12 @@ 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 is not None:
if self.result.exit_status is None:
msg = "Command '%s' failed and is not responding to signals"
msg %= self.command
......@@ -118,3 +119,5 @@ class CmdError(Exception):
msg = "Command '%s' failed (rc=%d)"
msg %= (self.command, self.result.exit_status)
return msg
else:
return "CmdError"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册