def run_cmd(self, cmd, collect, env=None):
out = []
if self.args.verbose:
self.logr(" CMD: %s" % cmd)
fh = None
if self.args.disable_cmd_redirection or collect == self.Want_Output:
fh = open(self.cov_paths['tmp_out'], 'w')
else:
fh = open(os.devnull, 'w')
if env is None:
subprocess.call(cmd, stdin=None,
stdout=fh, stderr=subprocess.STDOUT, shell=True, executable='/bin/bash')
else:
subprocess.call(cmd, stdin=None,
stdout=fh, stderr=subprocess.STDOUT, shell=True, env=env, executable='/bin/bash')
fh.close()
if self.args.disable_cmd_redirection or collect == self.Want_Output:
with open(self.cov_paths['tmp_out'], 'r') as f:
for line in f:
out.append(line.rstrip('\n'))
return out
评论列表
文章目录