fabric/fabric — pull request #740 by owenn (2012-09-27 08:53:20+00:00)
Title: Enabled extenss

Allows the creation of custom prompts and responses. I wrote it to allow custom contextmanagers as in

from fabric.api import env, run
import contextlib

@contextlib.contextmanager
def asu(user, asu_number):
'''Context manager to cause all run()'ed operations to be
priv('user')'ed.

Replaces env.shell with the priv command for the duration of the
context.
'''
save_shell = env.shell

save_current_prompts = env.request_prompts
env.request_prompts = { "Enter ASU #:" : asu_number, "Password:" : "testpassword" }

env.shell = '$HOME/asu %s -c' % user
yield
env.shell = save_shell
env.request_prompts = save_current_prompts