[Python-Dev] deprecate commands.getstatus()
titus at caltech.edu
Thu Mar 22 21:26:36 CET 2007
I posted about adding 'get_output', 'get_status_output', and
'get_status_output_errors' to subprocess here,
and got some interesting responses.
Briefly, my original proposal was to add these three functions:
output = get_output(cmd, input=None, cwd=None, env=None)
(status, output) = get_status_output(cmd, input=None, cwd=None, env=None)
(status, output, errout) = get_status_output_errors(cmd, input=None,
Commenters convinced me to propose a few additions. In order of
* first, all sensical keyword args to subprocess.Popen
(everything but universal_newlines, stdout, stderr, and bufsize,
which don't make much sense in the context of the proposed functions)
should be accepted by the 'get_' functions.
This complicates the function signatures but does make them
potentially much more useful.
* second, I'd like to add a 'require_success' bool keyword, that is
by default False (and does nothing in that case). However, when
True, the functions would emulate check_call, i.e. they would raise
CalledProcessError when the returncode was not zero.
* third, the 'popen2' module should be deprecated for 2.6. I don't see
that it has anything in it that subprocess doesn't have.
p.s. This has been a fun learning process... ;)
More information about the Python-Dev