2 # tshark module - refactored from test_scan.py
4 # Copyright (c) 2014, Qualcomm Atheros, Inc.
5 # Copyright (c) 2015, Intel Mobile Communications GmbH
7 # This software may be distributed under the terms of the BSD license.
8 # See README for more details.
13 logger = logging.getLogger()
16 _tshark_filter_arg = '-Y'
18 def run_tshark(filename, filter, display=None, wait=True):
19 global _tshark_filter_arg
22 # wait a bit to make it more likely for wlantest sniffer to have
23 # captured and written the results into a file that we can process here
27 arg = [ "tshark", "-r", filename,
28 _tshark_filter_arg, filter ]
30 arg.append('-Tfields')
36 cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
37 stderr=open('/dev/null', 'w'))
39 logger.info("Could run run tshark check: " + str(e))
43 out = cmd.communicate()[0]
46 # remember this for efficiency
47 _tshark_filter_arg = '-R'
49 cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
50 stderr=open('/dev/null', 'w'))
51 out = cmd.communicate()[0]