numpy.distutils.exec_command#

exec_command

实现了 exec_command 函数,该函数(几乎)等同于 commands.getstatusoutput 函数,但在 NT、DOS 系统上,返回的状态是正确的(尽管返回的状态值可能相差一个因子)。此外,exec_command 还接受关键字参数来(重新)定义环境变量。

提供的函数

exec_command — 在指定目录中执行命令,并在

修改后的环境中执行。

find_executable — 使用环境变量 PATH 中的信息定位命令。

相当于 posix 的 which 命令。

作者:Pearu Peterson <pearu@cens.ioc.ee> 创建:2003 年 1 月 11 日

需要:Python 2.x

已成功测试于

os.name

sys.platform

备注

posix

linux2

Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3 PyCrust 0.9.3, Idle 1.0.2

posix

linux2

Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2

posix

sunos5

SunOS 5.9, Python 2.2, 2.3.2

posix

darwin

Darwin 7.2.0, Python 2.3

nt

win32

Windows Me Python 2.3(EE), Idle 1.0, PyCrust 0.7.2 Python 2.1.1 Idle 0.8

nt

win32

Windows 98, Python 2.1.1. Idle 0.8

nt

win32

Cygwin 98-4.10, Python 2.1.1(MSC) - echo 测试失败,即重新定义环境变量可能不起作用。已修复:不要使用 cygwin echo!注释:cmd /c echo 也不起作用,但重新定义环境变量确实起作用。

posix

cygwin

Cygwin 98-4.10, Python 2.3.3(cygming special)

nt

win32

Windows XP, Python 2.3.3

已知 bug

  • 当从 MSYS 提示符执行时,发送消息到 stderr 的测试会失败,因为消息在某个点丢失了。

函数

exec_command(command[, execute_in, ...])

返回已执行命令的状态(status)和输出(output)。

filepath_from_subprocess_output(output)

将子进程使用的编码中的 bytes 转换为适合文件系统的 str

find_executable(exe[, path, _cache])

返回可执行文件的完整路径,否则返回 None。

forward_bytes_to_stdout(val)

将子进程调用中的字节转发到控制台,而不尝试解码它们。

get_pythonexe()

temp_file_name()