mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
update.py: use reader to decode subprocess output correctly
We can't decode UTF-8 characters byte-by-byte, as soon as we hit a character that's more than one byte long then we'll fail. Use a reader object to do it properly. This fixes parsing current meta-angstrom on master. At the same time, specify errors="surrogateescape" to avoid the update process dying at this point in case of characters that aren't valid UTF-8. Thanks to Jiajie Hu <jiajie.hu@intel.com> who fixed this in devtool's very similar code. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
19a559cfa6
commit
05b8528142
|
@ -11,6 +11,7 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
import codecs
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import signal
|
||||||
|
@ -45,10 +46,10 @@ def run_command_interruptible(cmd):
|
||||||
cmd, cwd=os.path.dirname(sys.argv[0]), shell=True, preexec_fn=reenable_sigint, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
cmd, cwd=os.path.dirname(sys.argv[0]), shell=True, preexec_fn=reenable_sigint, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
reader = codecs.getreader('utf-8')(process.stdout, errors='surrogateescape')
|
||||||
buf = ''
|
buf = ''
|
||||||
while True:
|
while True:
|
||||||
out = process.stdout.read(1)
|
out = reader.read(1, 1)
|
||||||
out = out.decode('utf-8')
|
|
||||||
if out:
|
if out:
|
||||||
sys.stdout.write(out)
|
sys.stdout.write(out)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user