[Python-Dev] 'commands' module on Win32
Nick Coghlan
ncoghlan at iinet.net.au
Fri Aug 13 12:39:26 CEST 2004
Bug #1008275 refers to attempting to run commands.getstatusoutput() on
win32, and the fact that it breaks.
The reason it breaks is because it expects a posix shell, and this is
noted in the documentation for the module (or rather, the module is
noted as only supported on Unix).
commands.getstatusoutput() and commands.getoutput() can easily be fixed
to run properly on Windows (using "if os.name == 'posix'" to select the
correct formatting for the shell command). Only the first one actually
needs to be fixed, since getoutput() just returns the second element of
the tuple returned by getstatusoutput()
The dirty holdout is commands.getstatus().
This function does *not* simply return the first element of the tuple
returned by commands.getstatusoutput() as you might expect. Instead of
returning the status code resulting from executing its argument as a
shell command, it insteads calls 'ls -ld <arg>' to get the file
information. (And this is a function in the commands module exactly why?)
This actually works for me, but only because I have MSYS & MINGW
installed :)
Anyway, getstatusoutput() and getoutput() seem like very handy ways to
make a command line call and get its results. I'd never seen them before
because they're squirelled away as Unix specific modules.
Are there any objections to changing this module so that only
getstatus() is marked as Unix specific?
I ask, because I don't want to start work on a documentation patch if
the idea is a non-starter (the code & test changes are already done,
butI think the hardest part of the exercise will be moving the
documentation out of the 'Unix-specific' part of the doc tree).
Cheers,
Nick.
--
Nick Coghlan | Eugene, Oregon
Email: ncoghlan at email.com | USA
More information about the Python-Dev
mailing list