提交 2b71c23e 编写于 作者: L Lucas Meneghel Rodrigues

avocado.utils.process: SubProcess -> Add .__repr__() method and reorganize __str__()

In order to show more clearly process information, add
a __repr__() method, and modify __str__() to the SubProcess
class.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 0e69b53c
......@@ -250,12 +250,23 @@ class SubProcess(object):
self.shell = shell
self._popen = None
def __str__(self):
if self.result.exit_status is None:
rc = '(still running)'
def __repr__(self):
if self._popen is None:
rc = '(not started)'
elif self.result.exit_status is None:
rc = '(running)'
else:
rc = self.result.exit_status
return 'SubProcess(cmd="%s", rc="%s")' % (self.cmd, rc)
return '%s(cmd=%r, rc=%r)' % (self.__class__.__name__, self.cmd, rc)
def __str__(self):
if self._popen is None:
rc = '(not started)'
elif self.result.exit_status is None:
rc = '(running)'
else:
rc = '(finished with exit status=%d)' % self.result.exit_status
return '%s %s' % (self.cmd, rc)
def _init_subprocess(self):
if self._popen is None:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册