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)

将子进程使用的编码中的 字节 转换为适合文件系统的 字符串

find_executable(exe[, path, _cache])

返回可执行文件的完整路径或 None。

forward_bytes_to_stdout(val)

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

get_pythonexe()

temp_file_name()