This patch contains several modifications of the summary. It is now
coloured in case it is printed to a terminal.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
lnst/Controller/NetTestResultSerializer.py | 29 ++++++++++++++++++++-------
1 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/lnst/Controller/NetTestResultSerializer.py
b/lnst/Controller/NetTestResultSerializer.py
index b41ac39..1e091e9 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -11,9 +11,10 @@ __author__ = """
jpirko(a)redhat.com (Jiri Pirko)
"""
+import logging
from xml.dom.minidom import getDOMImplementation
from lnst.Common.NetTestCommand import str_command
-import logging
+from lnst.Common.Colours import colourize, decorate_string
def serialize_obj(obj, dom, el, upper_name="unnamed"):
if isinstance(obj, dict):
@@ -227,18 +228,30 @@ class NetTestResultSerializer:
if len(right) > max_right:
max_right = len(right)
- full_length = max_left + max_right
+ # +1 for the alignment of " PASS" or " FAIL"
+ # +2 for spacing aroun the whole block
+ full_length = max_left + max_right + 1 + 2
+
if full_length % 2:
- full_length = full_length+2
+ full_length = full_length + 2
else:
- full_length = full_length+1
+ full_length = full_length + 1
+
+ header = " SUMMARY ".center(full_length, "=")
+ coloured_summary = colourize("SUMMARY", "blue", None, True)
+ logging.info(header.replace("SUMMARY", coloured_summary))
- logging.info("="*((full_length-9)/2) + " SUMMARY " +
"="*((full_length-9)/2))
for left, right in output_pairs:
if right != "":
- space_fill = full_length - len(left) - len(right)
+ space_fill = full_length - len(left) - len(right) - 1 - 2
+ if right == "PASS":
+ right = decorate_string(right, "pass")
+ elif right == "FAIL":
+ right = decorate_string(right, "fail")
+ right = " %s" % right
+
output = left + (space_fill)*" " + right
else:
- output = left
- logging.info(output)
+ output = left + " "
+ logging.info(" %s " % output)
logging.info("="*(full_length))
--
1.7.7.6