It seems like the function commands.getstatus() should
just return the status of a shell command, rather than
interpreting its argument as a filename and doing an
"ls -ld" on it and returning the output.
I would have thought the function would be implemented
like this (based on commands.getoutput):
def getstatus(cmd):
"""Return exit status of executing cmd in a
shell."""
return getstatusoutput(cmd)[0]
(Sorry for any line wrapping--the point is just to be
symmetrical with getoutput.)
Note also that closing a pipe can raise an exception,
even if useful output was captured from the command; it
may be convenient to put the pipe.close() in
commands.getstatusoutput() into a try block. But this
is probably an unlikely edge condition in most cases,
and I won't be sad if it doesn't happen :)
|