Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 尝试执行子流程调用时,没有此类文件或目录_Python - Fatal编程技术网

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