[英]piping make test output to disk using python
I am trying to dump output of make test
out to a text file instead of dumping in terminal shell using _subprocess.Popen(['make', 'test', '> & ', saveTo], shell=True, stdout=_subprocess.PIPE, stderr=_subprocess.PIPE, cwd=_os.getcwd())
where saveTo = "/username/Desktop/maketest.txt"
but it is not working, any help would be appreciated. 我试图将
make test
输出转储到文本文件中,而不是使用_subprocess.Popen(['make', 'test', '> & ', saveTo], shell=True, stdout=_subprocess.PIPE, stderr=_subprocess.PIPE, cwd=_os.getcwd())
转储到终端外壳中_subprocess.Popen(['make', 'test', '> & ', saveTo], shell=True, stdout=_subprocess.PIPE, stderr=_subprocess.PIPE, cwd=_os.getcwd())
,其中saveTo = "/username/Desktop/maketest.txt"
但它不起作用,任何帮助将不胜感激。 Cheers 干杯
You should use: 您应该使用:
saveTo = open("/username/Desktop/maketest.txt", "w")
p = subprocess.Popen("make test", shell=True, stdout=saveTo )
ret_code = p.wait()
saveTo.flush()
Not ['make', 'test'], but "make test" 不是 ['make','test'], 而是 “ make test”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.