Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -f first_ttl
# -m max_ttl
args = [
command,
'-n',
# -w wait time seconds
'-w1',
# -q number of queries
'-q1',
self.mtr_host,
]
# get both stdout and stderr
proc = self.popen(args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
with proc.stdout:
hosts = self.parse_traceroute(iter(proc.stdout.readline, b''))
return hosts
def _run_proc(self):
args = [
self.config['command'],
'-u',
'-C%d' % self.count,
'-p%d' % self.period,
'-e'
]
args.extend(self.hosts_args())
data = list()
# get both stdout and stderr
proc = self.popen(args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
# TODO poll, timeout, maybe from parent process for better control?
with proc.stdout:
for line in iter(proc.stdout.readline, b''):
data.append(self.parse_verbose(line.decode("utf-8")))
return data