@@ -943,28 +943,31 @@ def setColor(message, color=None, bold=False, level=None, istty=None):
943943
944944 retVal = message
945945
946- if message and (IS_TTY or istty ) and not conf .get ("disableColoring" ): # colorizing handler
947- if level is None :
948- levels = re .findall (r"\[(?P<result>%s)\]" % '|' .join (_ [0 ] for _ in getPublicTypeMembers (LOGGING_LEVELS )), message )
946+ if message :
947+ if (IS_TTY or istty ) and not conf .get ("disableColoring" ): # colorizing handler
948+ if level is None :
949+ levels = re .findall (r"\[(?P<result>%s)\]" % '|' .join (_ [0 ] for _ in getPublicTypeMembers (LOGGING_LEVELS )), message )
949950
950- if len (levels ) == 1 :
951- level = levels [0 ]
951+ if len (levels ) == 1 :
952+ level = levels [0 ]
952953
953- if bold or color :
954- retVal = colored (message , color = color , on_color = None , attrs = ("bold" ,) if bold else None )
955- elif level :
956- try :
957- level = getattr (logging , level , None )
958- except :
959- level = None
960- retVal = LOGGER_HANDLER .colorize (message , level )
961- else :
962- match = re .search (r"\(([^)]*)\s*fork\)" , message )
963- if match :
964- retVal = retVal .replace (match .group (1 ), colored (match .group (1 ), color = "lightgrey" ))
954+ if bold or color :
955+ retVal = colored (message , color = color , on_color = None , attrs = ("bold" ,) if bold else None )
956+ elif level :
957+ try :
958+ level = getattr (logging , level , None )
959+ except :
960+ level = None
961+ retVal = LOGGER_HANDLER .colorize (message , level )
962+ else :
963+ match = re .search (r"\(([^)]*)\s*fork\)" , message )
964+ if match :
965+ retVal = retVal .replace (match .group (1 ), colored (match .group (1 ), color = "lightgrey" ))
966+
967+ for match in re .finditer (r"([^\w])'([^\n']+)'" , message ): # single-quoted (Note: watch-out for the banner)
968+ retVal = retVal .replace (match .group (0 ), "%s'%s'" % (match .group (1 ), colored (match .group (2 ), color = "lightgrey" )))
965969
966- for match in re .finditer (r"([^\w])'([^\n']+)'" , message ): # single-quoted (Note: watch-out for the banner)
967- retVal = retVal .replace (match .group (0 ), "%s'%s'" % (match .group (1 ), colored (match .group (2 ), color = "lightgrey" )))
970+ message = message .strip ()
968971
969972 return retVal
970973
@@ -988,6 +991,12 @@ def dataToStdout(data, forceOutput=False, bold=False, contentType=None, status=C
988991 Writes text to the stdout (console) stream
989992 """
990993
994+ if not IS_TTY and isinstance (data , six .string_types ) and data .startswith ("\r " ):
995+ if re .search (r"\(\d+%\)" , data ):
996+ data = ""
997+ else :
998+ data = "\n %s" % data .strip ("\r " )
999+
9911000 if not kb .get ("threadException" ):
9921001 if forceOutput or not (getCurrentThreadData ().disableStdOut or kb .get ("wizardMode" )):
9931002 multiThreadMode = isMultiThreadMode ()
0 commit comments