mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ci: ttfw: Encode serial port data to whatever the console encoding is
This is a bit of a hack, but gives us a way to always log it
This commit is contained in:
parent
37838803db
commit
26fb74bc97
@ -40,6 +40,7 @@ If they using different port then need to implement their DUTPort class as well.
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import re
|
||||
import sys
|
||||
import threading
|
||||
import copy
|
||||
import functools
|
||||
@ -78,11 +79,12 @@ def _expect_lock(func):
|
||||
def _decode_data(data):
|
||||
""" for python3, if the data is bytes, then decode it to string """
|
||||
if isinstance(data, bytes):
|
||||
# convert bytes to string
|
||||
# convert bytes to string. This is a bit of a hack, we know that we want to log this
|
||||
# later so encode to the stdout encoding with backslash escapes for anything non-encodable
|
||||
try:
|
||||
data = data.decode("utf-8", "ignore")
|
||||
except UnicodeDecodeError:
|
||||
data = data.decode("iso8859-1", )
|
||||
return data.decode(sys.stdout.encoding, "backslashreplace")
|
||||
except UnicodeDecodeError: # Python <3.5 doesn't support backslashreplace
|
||||
return data.decode(sys.stdout.encoding, "replace")
|
||||
return data
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user