]> code.ossystems Code Review - openembedded-core.git/commitdiff
core/target/ssh.py: use reader to handle partial data
authorRobert Yang <liezhi.yang@windriver.com>
Thu, 24 Aug 2017 06:19:55 +0000 (23:19 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 24 Aug 2017 08:34:53 +0000 (09:34 +0100)
This can avoid UnicodeDecodeError error.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/core/target/ssh.py

index a2eafcd6f2a10ea870614ca67bbbadc33abfb915..927d659525b43b3e2b41ce1a1b8a420c59efec5b 100644 (file)
@@ -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