mirror of
https://git.rtems.org/rtems-tools/
synced 2025-05-15 22:07:00 +08:00
rtemstoolkit: Fix decoding unicode strings in output
This commit is contained in:
parent
12971a8b85
commit
b9d32b3bb5
@ -37,6 +37,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
import codecs
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -203,6 +204,10 @@ class execute(object):
|
|||||||
stacktraces.trace()
|
stacktraces.trace()
|
||||||
if trace_threads:
|
if trace_threads:
|
||||||
print('execute:_readthread: start')
|
print('execute:_readthread: start')
|
||||||
|
if sys.stdout.encoding is not None:
|
||||||
|
decoder = codecs.getincrementaldecoder(sys.stdout.encoding)()
|
||||||
|
else:
|
||||||
|
decoder = None
|
||||||
count = 0
|
count = 0
|
||||||
line = ''
|
line = ''
|
||||||
try:
|
try:
|
||||||
@ -222,8 +227,8 @@ class execute(object):
|
|||||||
_output_line(line + '\n', exe, prefix, out, count)
|
_output_line(line + '\n', exe, prefix, out, count)
|
||||||
break
|
break
|
||||||
# str and bytes are the same type in Python2
|
# str and bytes are the same type in Python2
|
||||||
if type(data) is not str and type(data) is bytes:
|
if decoder is not None and type(data) is not str and type(data) is bytes:
|
||||||
data = data.decode(sys.stdout.encoding)
|
data = decoder.decode(data)
|
||||||
last_ch = data[-1]
|
last_ch = data[-1]
|
||||||
sd = (line + data).split('\n')
|
sd = (line + data).split('\n')
|
||||||
if last_ch != '\n':
|
if last_ch != '\n':
|
||||||
@ -382,6 +387,9 @@ class execute(object):
|
|||||||
if self.verbose:
|
if self.verbose:
|
||||||
log.output(what + ': ' + cs)
|
log.output(what + ': ' + cs)
|
||||||
log.trace('exe: %s' % (cs))
|
log.trace('exe: %s' % (cs))
|
||||||
|
if shell and self.shell_exe:
|
||||||
|
command = arg_list(command)
|
||||||
|
command[:0] = self.shell_exe
|
||||||
if not stdin and self.input:
|
if not stdin and self.input:
|
||||||
stdin = subprocess.PIPE
|
stdin = subprocess.PIPE
|
||||||
if not stdout:
|
if not stdout:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user