Chris Withers wrote:
Hi All,
I have a script that does the following:
from subprocess import Popen,PIPE,STDOUT
def execute(command,cwd):
return Popen(
command,
stderr=STDOUT,
stdout=PIPE,
universal_newlines=True,
cwd=cwd,
shell=True,
).communicate()[0]
captured = execute('svn up .')
Now, if the subversion update requires authentication credentials, it
manages to write to the console running the above script, *and* read
input from it too.
This is a bit baffling to me, I thought Popen.communicate() was
happily hoovering all the output to stdout and stderr into the result
returned from communicate?
And, indeed, if I change the script instead to do:
import sys
f = open('test.py','w')
f.write('import sys; sys.stderr.write("Hello!\\n")')
f.close()
captured = execute('test.py')
...then the output is indeed captured. So, what is svn doing
differently? How is it escaping its jail?
Chris
You did not redirect stdin, so it is expected you can still read input
from the console. And it looks like svn is writting the credentials
prompt on stderr.
You may want to look at http://pysvn.tigris.org/docs/pysvn.html though.
JM
--
http://mail.python.org/mailman/listinfo/python-list