detect suprocess interaction

Robin Becker robin at reportlab.com
Fri Mar 23 18:17:00 CET 2007


I'm using subprocess to carry out svn commands (probably should use the svn api 
package, but that's a dependency too far). Anyhow my code looks like

from subprocess import Popen, PIPE
p = Popen((svn,'ls',u),stdout=PIPE,stderr=PIPE)
i = p.wait()

and this sort of thing works well under most circumstances. However, when this 
code is executed for the very first time by a particular user it hangs waiting 
on user input.

This code is being used purely for testing correctness of a particular svn url 
so in the normal case we want to throw away both stdout and stderr. In the 
exceptional case is it possible to detect that input is required and only in 
that case issue the current contents of stdout (presumably a request for a 
password)?

Clearly I need to supply some kind of input filelike object, but is this sort of 
thing possible.
-- 
Robin Becker




More information about the Python-list mailing list