error on windows with commands.getstatusoutput
Lee Harr
missive at hotmail.com
Sun Dec 28 19:23:39 EST 2008
>> cmd = '%s -y %s -l %s' % (conf.twistd, conf.tztac, conf.twistdlog)
>> status, output = commands.getstatusoutput(cmd)
> The commands module is Unix only. See its documentation :
> http://docs.python.org/library/commands.html
Ah. Doh!
I was going back and forth between all of the different ways
to do this (os.system, os.spawn*, commands.*, subprocess.*)
and lost track of the no windows for commands thing.
Too bad it can't raise a more meaningful error message...
Anyhow, I've replaced it with this:
from subprocess import Popen, PIPE, STDOUT
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE,
stderr=STDOUT, close_fds=True)
output, unused = p.communicate()
status = p.returncode
Does that look more windows-friendly?
_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
http://www.microsoft.com/windows/windowslive/photos.aspx
More information about the Python-list
mailing list