tests: Convert tshark output to string object for python3
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
7ab74770e7
commit
2a79a8ce14
1 changed files with 8 additions and 7 deletions
|
@ -45,12 +45,13 @@ def _run_tshark(filename, filter, display=None, wait=True):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
output = cmd.communicate()
|
output = cmd.communicate()
|
||||||
out = output[0]
|
out = output[0].decode(errors='ignore')
|
||||||
|
out1 = output[1].decode()
|
||||||
res = cmd.wait()
|
res = cmd.wait()
|
||||||
if res == 1:
|
if res == 1:
|
||||||
errmsg = "Some fields aren't valid"
|
errmsg = "Some fields aren't valid"
|
||||||
if errmsg in output[1]:
|
if errmsg in out1:
|
||||||
errors = output[1].split('\n')
|
errors = out1.split('\n')
|
||||||
fields = []
|
fields = []
|
||||||
collect = False
|
collect = False
|
||||||
for f in errors:
|
for f in errors:
|
||||||
|
@ -68,11 +69,11 @@ def _run_tshark(filename, filter, display=None, wait=True):
|
||||||
arg[3] = '-R'
|
arg[3] = '-R'
|
||||||
cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
|
cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
|
||||||
stderr=open('/dev/null', 'w'))
|
stderr=open('/dev/null', 'w'))
|
||||||
out = cmd.communicate()[0]
|
out = cmd.communicate()[0].decode()
|
||||||
cmd.wait()
|
cmd.wait()
|
||||||
if res == 2:
|
if res == 2:
|
||||||
if "tshark: Neither" in output[1] and "are field or protocol names" in output[1]:
|
if "tshark: Neither" in out1 and "are field or protocol names" in out1:
|
||||||
errors = output[1].split('\n')
|
errors = out1.split('\n')
|
||||||
fields = []
|
fields = []
|
||||||
for f in errors:
|
for f in errors:
|
||||||
if f.startswith("tshark: Neither "):
|
if f.startswith("tshark: Neither "):
|
||||||
|
@ -112,6 +113,6 @@ def run_tshark_json(filename, filter):
|
||||||
logger.info("Could run run tshark: " + str(e))
|
logger.info("Could run run tshark: " + str(e))
|
||||||
return None
|
return None
|
||||||
output = cmd.communicate()
|
output = cmd.communicate()
|
||||||
out = output[0]
|
out = output[0].decode()
|
||||||
res = cmd.wait()
|
res = cmd.wait()
|
||||||
return out
|
return out
|
||||||
|
|
Loading…
Reference in a new issue