I have a fabric task that looks like this:
@task
def test():
with settings(prompts={'This is a test.': 'q', 'question?':'answer'}):
run("python test.py")
my test.py script looks like this:
import subprocess, os
subprocess.call(['less', '-e', os.path.abspath('test.txt')])
response = raw_input("A question?")
print("response is [{0}]".format(response))
And test.txt contains:
This is a test.
If I run this, and I add a few prints in fabric to see what's happening, indeed when reading the file fabric finds the text, enters q. It then stops on raw_input, sends the response. But raw_input gets "" as an answer instead of response!!
If I remove 'question?':'answer' from my prompts dict, and enter the answer manually, again, it is somehow swallowed...
However if I remove 'This is a test.': 'q' and exit the less command manually, both manual or automatic response for the raw_input work again.
How can I exit less without my subsequent answers being swallowed? Of course, I simplified a real life scenario where I can't change these files...