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 |
已知錯誤
從 MSYS 提示字元執行時,傳送訊息到 stderr 的測試會失敗,因為訊息在某些時候遺失了。
函數
|
傳回已執行命令的 (狀態, 輸出)。 |
|
將子程序中使用的編碼的 bytes 轉換為適用於檔案系統的 str。 |
|
傳回可執行檔的完整路徑,如果找不到則傳回 None。 |
將來自子程序呼叫的位元組轉發到主控台,而不嘗試解碼它們。 |
|