aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2017-01-17 06:07:39 +0530
committerDeepak S <deepak.s@linux.intel.com>2017-01-19 06:25:22 +0530
commit0aa65ecf94ecbab93fa858607f1051535ac2d59e (patch)
tree49d1f9dbe02b1cf9208674e4ae45cd5e05d4a68a
parentea706beda50f87ae37799bd8f0313d177909a4ff (diff)
Verify stdin data before doing encodeutils safe_encode
Process running via ssh can return "None" or emtpy data from the application. To avoid encodutils raise NoneType issue. Check the data before encode. JIRA: YARDSTICK-539 Change-Id: I7e86e6a17c0adc95d41714f6fec463dfadc2b81b Signed-off-by: Deepak S <deepak.s@linux.intel.com>
-rw-r--r--yardstick/ssh.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/yardstick/ssh.py b/yardstick/ssh.py
index 1cad8eefa..cfbc3ca96 100644
--- a/yardstick/ssh.py
+++ b/yardstick/ssh.py
@@ -202,7 +202,7 @@ class SSH(object):
start_time = time.time()
# encode on transmit, decode on receive
- data_to_send = encodeutils.safe_encode("")
+ data_to_send = encodeutils.safe_encode("", incoming='utf-8')
stderr_data = None
# If we have data to be sent to stdin then `select' should also
@@ -234,8 +234,11 @@ class SSH(object):
if session.send_ready():
if stdin is not None and not stdin.closed:
if not data_to_send:
+ stdin_txt = stdin.read(4096)
+ if stdin_txt is None:
+ stdin_txt = ''
data_to_send = encodeutils.safe_encode(
- stdin.read(4096), incoming='utf-8')
+ stdin_txt, incoming='utf-8')
if not data_to_send:
# we may need to keep stdin open
if not keep_stdin_open: