Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_tshark_process(self, packet_count=None, stdin=None):
"""
Returns a new tshark process with previously-set parameters.
"""
xml_type = 'psml' if self.only_summaries else 'pdml'
parameters = [get_tshark_path(), '-l', '-n', '-T', xml_type] + self.get_parameters(packet_count=packet_count)
self.log.debug('Creating TShark subprocess with parameters: ' + ' '.join(parameters))
tshark_process = yield From(asyncio.create_subprocess_exec(*parameters,
stdout=subprocess.PIPE,
stderr=open(os.devnull, "w"),
stdin=stdin))
self.log.debug('TShark subprocess created')
if tshark_process.returncode is not None and tshark_process.returncode != 0:
raise TSharkCrashException(
'TShark seems to have crashed. Try updating it. (command ran: "%s")' % ' '.join(parameters))
self.running_processes.add(tshark_process)
raise Return(tshark_process)