numpy.distutils.exec_command#
exec_command
實作 exec_command 函式,其(幾乎)等同於 commands.getstatusoutput 函式,但在 NT、DOS 系統上,回傳的狀態實際上是正確的(儘管回傳的狀態值可能相差一個係數)。此外,exec_command 接受關鍵字參數來(重新)定義環境變數。
提供函式
- exec_command — 在指定目錄中執行命令,以及
在修改後的環境中。
- find_executable — 使用來自環境的資訊定位命令
變數 PATH。等同於 posix which 命令。
Author: Pearu Peterson <pearu@cens.ioc.ee> Created: 11 January 2003
需求:Python 2.x
成功測試於
os.name |
sys.platform |
comments |
---|---|---|
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 tests fail i.e. redefining environment variables may not work. FIXED: don’t use cygwin echo! Comment: also cmd /c echo will not work but redefining environment variables do work. |
posix |
cygwin |
Cygwin 98-4.10, Python 2.3.3(cygming special) |
nt |
win32 |
Windows XP, Python 2.3.3 |
已知錯誤
從 MSYS 提示字元執行時,將訊息傳送到 stderr 的測試會失敗,因為訊息在某個時間點遺失了。
函式
|
回傳已執行命令的 (狀態, 輸出)。 |
|
將子程序使用的編碼中的 bytes 轉換為適用於檔案系統的 str。 |
|
回傳可執行檔的完整路徑,若找不到則回傳 None。 |
將來自子程序呼叫的位元組轉發到主控台,而不嘗試解碼它們。 |
|