mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
core/target/ssh.py: use reader to handle partial data
This can avoid UnicodeDecodeError error. (From OE-Core rev: baa78420d8d8e716935852c9c7b749af0161395a) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
1db2a8577c
commit
b261fca0dc
@@ -6,6 +6,7 @@ import time
|
|||||||
import select
|
import select
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import codecs
|
||||||
|
|
||||||
from . import OETarget
|
from . import OETarget
|
||||||
|
|
||||||
@@ -206,12 +207,12 @@ def SSHCall(command, logger, timeout=None, **opts):
|
|||||||
logger.debug('time: %s, endtime: %s' % (time.time(), endtime))
|
logger.debug('time: %s, endtime: %s' % (time.time(), endtime))
|
||||||
try:
|
try:
|
||||||
if select.select([process.stdout], [], [], 5)[0] != []:
|
if select.select([process.stdout], [], [], 5)[0] != []:
|
||||||
data = os.read(process.stdout.fileno(), 1024)
|
reader = codecs.getreader('utf-8')(process.stdout)
|
||||||
|
data = reader.read(1024, 1024)
|
||||||
if not data:
|
if not data:
|
||||||
process.stdout.close()
|
process.stdout.close()
|
||||||
eof = True
|
eof = True
|
||||||
else:
|
else:
|
||||||
data = data.decode("utf-8", errors='replace')
|
|
||||||
output += data
|
output += data
|
||||||
logger.debug('Partial data from SSH call: %s' % data)
|
logger.debug('Partial data from SSH call: %s' % data)
|
||||||
endtime = time.time() + timeout
|
endtime = time.time() + timeout
|
||||||
|
|||||||
Reference in New Issue
Block a user