Python Fabric: How to answer to keyboard input? Python Fabric: How to answer to keyboard input? python python

Python Fabric: How to answer to keyboard input?


If you are looking for a user to confirm an operation, use the confrim method.

if fabric.contrib.console.confirm("You tests failed do you want to continue?"):  #continue processing

Or if you are looking for a way to get input from the user, use the prompt method.

password = fabric.operations.prompt("What is your password?")


Why can't you just use pipes?

For example, for an automated auto accept, just use yes, that just outputs a neverending stream of y.

yes | rm *.txt


(source: wikimedia.org)


Those both methods are valid and works.

I choose the first one, because I didn't want to have any interaction with my deployment system.

So here is the solution I used:

% yes | ./manage.py rebuild_index

WARNING: This will irreparably remove EVERYTHING from your search index.Your choices after this are to restore from backups or rebuild via the rebuild_index command.Are you sure you wish to continue? [y/N] Removing all documents from your index because you said so.All documents removed.Indexing 27 Items.