mirror of
https://git.yoctoproject.org/poky
synced 2026-05-09 05:29:32 +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 logging
|
||||
import subprocess
|
||||
import codecs
|
||||
|
||||
from . import OETarget
|
||||
|
||||
@@ -206,12 +207,12 @@ def SSHCall(command, logger, timeout=None, **opts):
|
||||
logger.debug('time: %s, endtime: %s' % (time.time(), endtime))
|
||||
try:
|
||||
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:
|
||||
process.stdout.close()
|
||||
eof = True
|
||||
else:
|
||||
data = data.decode("utf-8", errors='replace')
|
||||
output += data
|
||||
logger.debug('Partial data from SSH call: %s' % data)
|
||||
endtime = time.time() + timeout
|
||||
|
||||
Reference in New Issue
Block a user