[SWDEV-464799] Handle UnicodeEncodeError with non UTF-8 locales
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Change-Id: Ifb8e6e3c7891c4f70faba5441fb87cc4ba2302f3
[ROCm/rocm_smi_lib commit: c2235eea35]
This commit is contained in:
@@ -871,7 +871,13 @@ def printLog(device, metricName, value=None, extraSpace=False, useItalics=False)
|
||||
try:
|
||||
if extraSpace:
|
||||
print('\n', end='')
|
||||
print(logstr + '\n', end='')
|
||||
|
||||
# Handle non UTF-8 locale
|
||||
try:
|
||||
print(logstr + '\n', end='')
|
||||
except UnicodeEncodeError:
|
||||
print(logstr.encode('ascii', 'ignore').decode('ascii'))
|
||||
|
||||
sys.stdout.flush()
|
||||
# when piped into programs like 'head' - print throws an error.
|
||||
# silently ignore instead
|
||||
|
||||
مرجع در شماره جدید
Block a user