Python 尝试执行子流程调用时,没有此类文件或目录
前言:我知道以前有人问过这个问题,但我无法从前面的答案中找到解决错误的方法 我只想调用Python 尝试执行子流程调用时,没有此类文件或目录,python,Python,前言:我知道以前有人问过这个问题,但我无法从前面的答案中找到解决错误的方法 我只想调用diff,在同一个文件上输出两个不同的命令 import os, sys from subprocess import check_call import shlex ourCompiler = 'espressoc'; checkCompiler = 'espressocr'; indir = 'Tests/Espresso/GoodTests'; check_call(["pwd"]);
diff
,在同一个文件上输出两个不同的命令
import os, sys
from subprocess import check_call
import shlex
ourCompiler = 'espressoc';
checkCompiler = 'espressocr';
indir = 'Tests/Espresso/GoodTests';
check_call(["pwd"]);
for root, dirs, filenames in os.walk(indir):
for f in filenames:
if len(sys.argv) == 2 and sys.argv[1] == f:
str1 = "<(./%s ./%s) " % (ourCompiler, os.path.join(root, f))
str2 = "<(./%s ./%s) " % (checkCompiler, os.path.join(root, f))
check_call(["diff", str1, str2])
导入操作系统,系统
从子流程导入检查调用
导入shlex
我们的编译器=‘浓缩咖啡’;
checkCompiler='espressocr';
indir=‘测试/浓缩咖啡/好的测试’;
检查呼叫([“pwd”]);
对于os.walk(indir)中的根目录、目录和文件名:
对于文件名中的f:
如果len(sys.argv)==2和sys.argv[1]==f:
str1=“
diff
正在抱怨找不到具有奇怪名称的文件
diff: <(./espressoc ./Tests/Espresso/GoodTests/Init.java) : No such file or directory
diff: <(./espressocr ./Tests/Espresso/GoodTests/Init.java) : No such file or directory
Traceback (most recent call last):
File "runTest.py", line 21, in <module>
check_call(["diff", str1, str2])
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['diff', '<(./espressoc ./Tests/Espresso/GoodTests/Init.java) ', '<(./espressocr ./Tests/Espresso/GoodTests/Init.java) ']' returned non-zero exit status 2
subprocess.check_call(['diff', '<this', '<that'])` # strange files.
subprocess.check_call('diff <this <that', shell=True)` # /bin/sh does some redirection