Created
September 17, 2011 22:51
-
-
Save tomviner/1224460 to your computer and use it in GitHub Desktop.
VirtualEnvWrappers with Fabric
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def once(s): | |
"command_prefixes is a list of prefixes" | |
if s not in env.command_prefixes: | |
return s | |
return 'true' | |
@contextlib.contextmanager | |
def mycd(dir): | |
with prefix(once('cd %s' % dir)): | |
yield | |
@contextlib.contextmanager | |
def vwrap(): | |
with prefix(once('source /usr/local/bin/virtualenvwrapper.sh')): | |
yield | |
@contextlib.contextmanager | |
def workon(ve): | |
with vwrap(): | |
with prefix(once('workon %s' %ve)): | |
yield |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment