summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-05-26 19:04:21 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-05-26 19:04:21 (GMT)
commita23810f86a53e394936b38ed9c6104fe2cc592cf (patch)
treef39d39741d348f914c151484fce95af2b33b295f /Doc
parent35af8d4218138e74f37a083b7e3c8abd4c0f1c11 (diff)
downloadcpython-a23810f86a53e394936b38ed9c6104fe2cc592cf.zip
cpython-a23810f86a53e394936b38ed9c6104fe2cc592cf.tar.gz
cpython-a23810f86a53e394936b38ed9c6104fe2cc592cf.tar.bz2
The commands module has been removed. The getoutput() and getstatusoutput()
functions have been added to the subprocess module. The fixer for this still needs to be written and proper Py3K deprecation warnings for the functions that didn't make the transition need to be done in 2.6. This is all part of trying to close issue #2872.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/commands.rst53
-rw-r--r--Doc/library/subprocess.rst32
-rw-r--r--Doc/library/unix.rst1
3 files changed, 30 insertions, 56 deletions
diff --git a/Doc/library/commands.rst b/Doc/library/commands.rst
deleted file mode 100644
index 79e3d73..0000000
--- a/Doc/library/commands.rst
+++ /dev/null
@@ -1,53 +0,0 @@
-
-:mod:`commands` --- Utilities for running commands
-==================================================
-
-.. module:: commands
- :platform: Unix
- :synopsis: Utility functions for running external commands.
-.. sectionauthor:: Sue Williams <sbw@provis.com>
-
-
-The :mod:`commands` module contains wrapper functions for :func:`os.popen` which
-take a system command as a string and return any output generated by the command
-and, optionally, the exit status.
-
-The :mod:`subprocess` module provides more powerful facilities for spawning new
-processes and retrieving their results. Using the :mod:`subprocess` module is
-preferable to using the :mod:`commands` module.
-
-The :mod:`commands` module defines the following functions:
-
-
-.. function:: getstatusoutput(cmd)
-
- Execute the string *cmd* in a shell with :func:`os.popen` and return a 2-tuple
- ``(status, output)``. *cmd* is actually run as ``{ cmd ; } 2>&1``, so that the
- returned output will contain output or error messages. A trailing newline is
- stripped from the output. The exit status for the command can be interpreted
- according to the rules for the C function :cfunc:`wait`.
-
-
-.. function:: getoutput(cmd)
-
- Like :func:`getstatusoutput`, except the exit status is ignored and the return
- value is a string containing the command's output.
-
-Example::
-
- >>> import commands
- >>> commands.getstatusoutput('ls /bin/ls')
- (0, '/bin/ls')
- >>> commands.getstatusoutput('cat /bin/junk')
- (256, 'cat: /bin/junk: No such file or directory')
- >>> commands.getstatusoutput('/bin/junk')
- (256, 'sh: /bin/junk: not found')
- >>> commands.getoutput('ls /bin/ls')
- '/bin/ls'
-
-
-.. seealso::
-
- Module :mod:`subprocess`
- Module for spawning and managing subprocesses.
-
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index b08b4ef..38f4063 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -14,7 +14,6 @@ replace several other, older modules and functions, such as::
os.system
os.spawn*
- commands.*
Information about how the :mod:`subprocess` module can be used to replace these
modules and functions can be found in the following sections.
@@ -113,7 +112,7 @@ This module defines one class called :class:`Popen`:
Convenience Functions
^^^^^^^^^^^^^^^^^^^^^
-This module also defines two shortcut functions:
+This module also defines four shortcut functions:
.. function:: call(*popenargs, **kwargs)
@@ -138,6 +137,35 @@ This module also defines two shortcut functions:
check_call(["ls", "-l"])
+.. function:: getstatusoutput(cmd)
+ Return ``(status, output)`` of executing *cmd* in a shell.
+
+ Execute the string *cmd* in a shell with :func:`os.popen` and return a 2-tuple
+ ``(status, output)``. *cmd* is actually run as ``{ cmd ; } 2>&1``, so that the
+ returned output will contain output or error messages. A trailing newline is
+ stripped from the output. The exit status for the command can be interpreted
+ according to the rules for the C function :cfunc:`wait`. Example::
+
+ >>> import subprocess
+ >>> subprocess.getstatusoutput('ls /bin/ls')
+ (0, '/bin/ls')
+ >>> subprocess.getstatusoutput('cat /bin/junk')
+ (256, 'cat: /bin/junk: No such file or directory')
+ >>> subprocess.getstatusoutput('/bin/junk')
+ (256, 'sh: /bin/junk: not found')
+
+
+.. function:: getoutput(cmd)
+ Return output ``(stdout or stderr)`` of executing *cmd* in a shell.
+
+ Like :func:`getstatusoutput`, except the exit status is ignored and the return
+ value is a string containing the command's output. Example::
+
+ >>> import subprocess
+ >>> subprocess.getoutput('ls /bin/ls')
+ '/bin/ls'
+
+
Exceptions
^^^^^^^^^^
diff --git a/Doc/library/unix.rst b/Doc/library/unix.rst
index 1b1592e..7cb54c2 100644
--- a/Doc/library/unix.rst
+++ b/Doc/library/unix.rst
@@ -25,4 +25,3 @@ of it. Here's an overview:
resource.rst
nis.rst
syslog.rst
- commands.rst