mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/ci_example_test' into 'master'
tools: Make Utility.console_log accept Unicode and byte strings as well See merge request idf/esp-idf!3367
This commit is contained in:
commit
84d2f510ea
@ -3,18 +3,18 @@ import sys
|
||||
|
||||
|
||||
_COLOR_CODES = {
|
||||
"white": '\033[0m',
|
||||
"red": '\033[31m',
|
||||
"green": '\033[32m',
|
||||
"orange": '\033[33m',
|
||||
"blue": '\033[34m',
|
||||
"purple": '\033[35m',
|
||||
"W": '\033[0m',
|
||||
"R": '\033[31m',
|
||||
"G": '\033[32m',
|
||||
"O": '\033[33m',
|
||||
"B": '\033[34m',
|
||||
"P": '\033[35m'
|
||||
"white": u'\033[0m',
|
||||
"red": u'\033[31m',
|
||||
"green": u'\033[32m',
|
||||
"orange": u'\033[33m',
|
||||
"blue": u'\033[34m',
|
||||
"purple": u'\033[35m',
|
||||
"W": u'\033[0m',
|
||||
"R": u'\033[31m',
|
||||
"G": u'\033[32m',
|
||||
"O": u'\033[33m',
|
||||
"B": u'\033[34m',
|
||||
"P": u'\033[35m'
|
||||
}
|
||||
|
||||
|
||||
@ -29,8 +29,10 @@ def console_log(data, color="white", end="\n"):
|
||||
if color not in _COLOR_CODES:
|
||||
color = "white"
|
||||
color_codes = _COLOR_CODES[color]
|
||||
if type(data) is type(b''):
|
||||
data = data.decode('utf-8', 'replace')
|
||||
print(color_codes + data, end=end)
|
||||
if color not in ["white", "W"]:
|
||||
# reset color to white for later logs
|
||||
print(_COLOR_CODES["white"] + "\r")
|
||||
print(_COLOR_CODES["white"] + u"\r")
|
||||
sys.stdout.flush()
|
||||
|
Loading…
Reference in New Issue
Block a user