提交 0a9a905c 编写于 作者: C Cleber Rosa

avocado/utils/process.py: drop __str__ and __repr__ of command results and errors

There's just so much implicit conversion on those methods that makes
them an enourmous source of errors (including UnicodeErrors).  The
information is still all there, and users are free to interpret them
as they see fit.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 ea54e407
......@@ -82,23 +82,6 @@ class CmdError(Exception):
self.result = result
self.additional_text = additional_text
def __str__(self):
if self.result is not None:
if self.result.interrupted:
msg = "Command '%s' interrupted by %s"
msg %= (self.command, self.result.interrupted)
elif 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)
if self.additional_text:
msg += ", " + self.additional_text
return msg
else:
return "CmdError"
def normalize_cmd(cmd, encoding=None):
"""
......@@ -357,19 +340,6 @@ class CmdResult(object):
return self.stderr
raise TypeError("Unable to decode stderr into a string-like type")
def __repr__(self):
cmd_rep = ("Command: %s\n"
"Exit status: %s\n"
"Duration: %s\n"
"Stdout:\n%s\n"
"Stderr:\n%s\n"
"PID:\n%s\n" % (self.command, self.exit_status,
self.duration, self.stdout, self.stderr,
self.pid))
if self.interrupted:
cmd_rep += "Command interrupted by %s\n" % self.interrupted
return cmd_rep
class FDDrainer(object):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册