I am trying to do a CVS login from Python by calling the cvs.exe process. When calling cvs.exe by hand, it prints a message to the console and then waits for the user to input the password.
When calling it with subprocess.Popen, I’ve noticed that the call blocks. The code is
subprocess.Popen(cvscmd, shell = True, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
I assume that it blocks because it’s waiting for input, but my expectation was that calling Popen would return immediately and then I could call subprocess.communicate() to input the actual password. How can I achieve this behaviour and avoid blocking on Popen?
OS: Windows XP
Python: 2.6
cvs.exe: 1.11
shell=Truepart. Your shell has nothing to do with it. Usingshell=Trueis a common cause of trouble.Example:
This won’t block on my system (my script continues executing). However since cvs reads the password directly from the terminal (not from standard input or output) you can’t just write the password to the subprocess’ stdin.
What you could do is pass the password as part of the CVSROOT specification instead, like this:
I.e. a function to login to a sourceforge project:
This works for me. Calling
Will log in anonymously to the bayonne project’s cvs.