]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Convert tshark output to string object for python3
authorJouni Malinen <j@w1.fi>
Sat, 2 Feb 2019 11:05:16 +0000 (13:05 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 4 Feb 2019 10:26:33 +0000 (12:26 +0200)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/tshark.py

index 81aee6c4b92939b015245f70ed46ac9abfbe2251..6a84b82966144c2615952070245f19f6313e3c3a 100644 (file)
@@ -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