subprocess.Popen takes a PIPE for stdin

http://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate

   Note that if you want to send data to the process’s stdin, you need to
   create the Popen object with stdin=PIPE.