From 247f95e051d62d66ae16f2d6d8fe7d56ce6439c7 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Wed, 11 Jul 2012 22:48:27 +0100 Subject: [PATCH] restored kb.currentMessage - needed in cases where we send to dataToStdout() strings like "." (e.g. "creation in progres ..... done") --- lib/core/common.py | 9 ++++++--- lib/core/option.py | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 0e5786228..c8c1db0a5 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -697,10 +697,13 @@ def singleTimeLogMessage(message, level=logging.INFO, flag=None): def setColor(message, bold=False): retVal = message - level = extractRegexResult(r"\A\s*\[(?P[A-Z ]+)\]", message) + level = extractRegexResult(r"\[(?P[A-Z ]+)\]", message) - if hasattr(LOGGER_HANDLER, "level_map"): - _ = LOGGER_HANDLER.level_map.get(logging.getLevelName(level)) + if level: + kb.currentMessage = level + + if hasattr(LOGGER_HANDLER, "level_map") and hasattr(kb, "currentMessage") and kb.currentMessage: + _ = LOGGER_HANDLER.level_map.get(logging.getLevelName(kb.currentMessage)) if _: background, foreground, bold = _ retVal = colored(message, color=foreground, on_color="on_%s" % background if background else None, attrs=("bold",) if bold else None) diff --git a/lib/core/option.py b/lib/core/option.py index 6b96e5d45..431139e16 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1436,6 +1436,7 @@ def __setKnowledgeBaseAttributes(flushAll=True): kb.commonOutputs = None kb.counters = {} + kb.currentMessage = None kb.data = AttribDict() kb.dataOutputFlag = False