I'm making a program that interacts with the Sphinx-Quickstart. So what I want to do is that my program recognises the word "path" and then enter a specific value. The same case with the others, and when I don't have a specific word, simply enter a enter ('\n'). I do this because Sphinx sometimes changes the order of the questions and if I use a communicate they can fail.
I think about something like this:
import subprocess
from subprocess import PIPE
p = subprocess.Popen('sphinx-quickstart', stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=PIPE, shell=True, bufsize=0)
p.stdin.write('doc\n')
a=p.stdout.readline()
print a.read()
while out:
line = out
line = line.rstrip("\n")
if "autodoc" in line:
pr = 1
p.stdin.write('y\n')
out = p.stdout.readline()
continue
if "source and build" in line:
pr = 2
p.stdin.write('y\n')
out = p.stdout.readline()
continue
out = p.stdout.readline()
p.stdin.close()
p.wait()
My program hangs when I try to read the output.
Thanks for your questions