From 2a79a8ce146b23f06331bb7450eca7c72bae2310 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 2 Feb 2019 13:05:16 +0200 Subject: [PATCH] tests: Convert tshark output to string object for python3 Signed-off-by: Jouni Malinen --- tests/hwsim/tshark.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/hwsim/tshark.py b/tests/hwsim/tshark.py index 81aee6c4b..6a84b8296 100644 --- a/tests/hwsim/tshark.py +++ b/tests/hwsim/tshark.py @@ -45,12 +45,13 @@ def _run_tshark(filename, filter, display=None, wait=True): return None output = cmd.communicate() - out = output[0] + out = output[0].decode(errors='ignore') + out1 = output[1].decode() res = cmd.wait() if res == 1: errmsg = "Some fields aren't valid" - if errmsg in output[1]: - errors = output[1].split('\n') + if errmsg in out1: + errors = out1.split('\n') fields = [] collect = False for f in errors: @@ -68,11 +69,11 @@ def _run_tshark(filename, filter, display=None, wait=True): arg[3] = '-R' cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, stderr=open('/dev/null', 'w')) - out = cmd.communicate()[0] + out = cmd.communicate()[0].decode() cmd.wait() if res == 2: - if "tshark: Neither" in output[1] and "are field or protocol names" in output[1]: - errors = output[1].split('\n') + if "tshark: Neither" in out1 and "are field or protocol names" in out1: + errors = out1.split('\n') fields = [] for f in errors: if f.startswith("tshark: Neither "): @@ -112,6 +113,6 @@ def run_tshark_json(filename, filter): logger.info("Could run run tshark: " + str(e)) return None output = cmd.communicate() - out = output[0] + out = output[0].decode() res = cmd.wait() return out