summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-07 15:30:06 (GMT)
committerGeorg Brandl <georg@python.org>2008-12-07 15:30:06 (GMT)
commitf9734076cf12444fb1b5e4296993bf6df3b1e7f2 (patch)
tree1a07422957dfa4cafe9868efd8965ab9abd6cf86 /Doc
parent2080ea5f4b7ab8bd9ab0385c7ac925731d78405e (diff)
downloadcpython-f9734076cf12444fb1b5e4296993bf6df3b1e7f2.zip
cpython-f9734076cf12444fb1b5e4296993bf6df3b1e7f2.tar.gz
cpython-f9734076cf12444fb1b5e4296993bf6df3b1e7f2.tar.bz2
Merged revisions 67511,67536-67537,67543 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67511 | vinay.sajip | 2008-12-04 00:22:58 +0100 (Thu, 04 Dec 2008) | 1 line Issue #4384: Added logging integration with warnings module using captureWarnings(). This change includes a NullHandler which does nothing; it will be of use to library developers who want to avoid the "No handlers could be found for logger XXX" message which can appear if the library user doesn't configure logging. ........ r67536 | gregory.p.smith | 2008-12-04 21:21:09 +0100 (Thu, 04 Dec 2008) | 3 lines Adds a subprocess.check_call_output() function to return the output from a process on success or raise an exception on error. ........ r67537 | vinay.sajip | 2008-12-04 21:32:18 +0100 (Thu, 04 Dec 2008) | 1 line Took Nick Coghlan's advice about importing warnings globally in logging, to avoid the possibility of race conditions: "This could deadlock if a thread spawned as a side effect of importing a module happens to trigger a warning. warnings is pulled into sys.modules as part of the interpreter startup - having a global 'import warnings' shouldn't have any real effect on logging's import time." ........ r67543 | gregory.p.smith | 2008-12-05 03:27:01 +0100 (Fri, 05 Dec 2008) | 2 lines rename the new check_call_output to check_output. its less ugly. ........
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/logging.rst15
-rw-r--r--Doc/library/subprocess.rst26
2 files changed, 40 insertions, 1 deletions
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
index e19f189..7c104b7 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -459,6 +459,12 @@ should have the desired effect. If an organisation produces a number of
libraries, then the logger name specified can be "orgname.foo" rather than
just "foo".
+.. versionadded:: 3.1
+
+The :class:`NullHandler` class was not present in previous versions, but is now
+included, so that it need not be defined in library code.
+
+
Logging Levels
--------------
@@ -551,6 +557,15 @@ provided:
#. :class:`HTTPHandler` instances send error messages to an HTTP server using
either ``GET`` or ``POST`` semantics.
+#. :class:`NullHandler` instances do nothing with error messages. They are used
+ by library developers who want to use logging, but want to avoid the "No
+ handlers could be found for logger XXX" message which can be displayed if
+ the library user has not configured logging.
+
+.. versionadded:: 3.1
+
+The :class:`NullHandler` class was not present in previous versions.
+
The :class:`StreamHandler` and :class:`FileHandler` classes are defined in the
core logging package. The other handlers are defined in a sub- module,
:mod:`logging.handlers`. (There is also another sub-module,
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 6aff816..588b3e1 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -156,6 +156,30 @@ This module also defines four shortcut functions:
check_call(["ls", "-l"])
+.. function:: check_output(*popenargs, **kwargs)
+
+ Run command with arguments and return its output as a byte string.
+
+ If the exit code was non-zero it raises a CalledProcessError. The
+ CalledProcessError object will have the return code in the returncode
+ attribute and output in the output attribute.
+
+ The arguments are the same as for the Popen constructor. Example:
+
+ >>> subprocess.check_output(["ls", "-l", "/dev/null"])
+ 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
+
+ The stdout argument is not allowed as it is used internally.
+ To capture standard error in the result, use stderr=subprocess.STDOUT.
+
+ >>> subprocess.check_output(
+ ["/bin/sh", "-c", "ls non_existant_file ; exit 0"],
+ stderr=subprocess.STDOUT)
+ 'ls: non_existant_file: No such file or directory\n'
+
+ .. versionadded:: 3.1
+
+
.. function:: getstatusoutput(cmd)
Return ``(status, output)`` of executing *cmd* in a shell.
@@ -175,7 +199,7 @@ This module also defines four shortcut functions:
.. function:: getoutput(cmd)
- Return output ``(stdout or stderr)`` of executing *cmd* in a shell.
+ Return output (stdout and 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::