[Piglit] [PATCH 1/2] framework/log.py: ensure any previous output is cleared
Thomas Wood
thomas.wood at intel.com
Fri Mar 21 06:55:10 PDT 2014
If the new summary line is shorter than the previous one, clear the
remaining characters.
Signed-off-by: Thomas Wood <thomas.wood at intel.com>
---
framework/log.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/framework/log.py b/framework/log.py
index cdc3e94..96f757e 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -41,6 +41,8 @@ class Log(object):
self.__summary_keys = set(['pass', 'fail', 'warn', 'crash', 'skip',
'dmesg-warn', 'dmesg-fail', 'dry-run', 'timeout'])
self.__summary = collections.defaultdict(lambda: 0)
+ self.__verbose = verbose
+ self.__lastlength = 0
self.__output = "[{percent}] {summary} {running}\r"
if verbose:
@@ -64,11 +66,19 @@ class Log(object):
def __print(self, name, result):
""" Do the actual printing """
- sys.stdout.write(self.__output.format(**{'percent': self._percent(),
- 'running': self._running(),
- 'summary': self._summary(),
- 'name': name,
- 'result': result}))
+ output = self.__output.format(**{'percent': self._percent(),
+ 'running': self._running(),
+ 'summary': self._summary(),
+ 'name': name,
+ 'result': result})
+
+ length = len(output)
+ if self.__lastlength > length:
+ output = output[:-1] + (" " * (self.__lastlength - length)) + '\r'
+
+ self.__lastlength = length
+
+ sys.stdout.write(output)
# Need to flush explicitly, otherwise it all gets buffered without a
# newline.
--
1.8.5.3
More information about the Piglit
mailing list