diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2017-08-23 23:19:55 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-24 13:48:10 +0100 |
commit | b261fca0dcacf6f8bdef1f8c5ff8ad1e0f6cd182 (patch) | |
tree | 196f4dc1329381b74ca7b4b261513d6479309e59 | |
parent | 1db2a8577c21f2d3dd2f143b6220df315a991169 (diff) | |
download | poky-b261fca0dcacf6f8bdef1f8c5ff8ad1e0f6cd182.tar.gz |
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>
-rw-r--r-- | meta/lib/oeqa/core/target/ssh.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py index a2eafcd6f2..927d659525 100644 --- a/meta/lib/oeqa/core/target/ssh.py +++ b/meta/lib/oeqa/core/target/ssh.py | |||
@@ -6,6 +6,7 @@ import time | |||
6 | import select | 6 | import select |
7 | import logging | 7 | import logging |
8 | import subprocess | 8 | import subprocess |
9 | import codecs | ||
9 | 10 | ||
10 | from . import OETarget | 11 | from . import OETarget |
11 | 12 | ||
@@ -206,12 +207,12 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
206 | logger.debug('time: %s, endtime: %s' % (time.time(), endtime)) | 207 | logger.debug('time: %s, endtime: %s' % (time.time(), endtime)) |
207 | try: | 208 | try: |
208 | if select.select([process.stdout], [], [], 5)[0] != []: | 209 | if select.select([process.stdout], [], [], 5)[0] != []: |
209 | data = os.read(process.stdout.fileno(), 1024) | 210 | reader = codecs.getreader('utf-8')(process.stdout) |
211 | data = reader.read(1024, 1024) | ||
210 | if not data: | 212 | if not data: |
211 | process.stdout.close() | 213 | process.stdout.close() |
212 | eof = True | 214 | eof = True |
213 | else: | 215 | else: |
214 | data = data.decode("utf-8", errors='replace') | ||
215 | output += data | 216 | output += data |
216 | logger.debug('Partial data from SSH call: %s' % data) | 217 | logger.debug('Partial data from SSH call: %s' % data) |
217 | endtime = time.time() + timeout | 218 | endtime = time.time() + timeout |