Skip to content

Instantly share code, notes, and snippets.

@pavelik
Forked from twneale/gist:6855493
Created March 25, 2018 12:43
Show Gist options
  • Save pavelik/0a2aa52e34b2cca507a00dbc9b2c4f41 to your computer and use it in GitHub Desktop.
Save pavelik/0a2aa52e34b2cca507a00dbc9b2c4f41 to your computer and use it in GitHub Desktop.

Revisions

  1. @twneale twneale revised this gist Oct 6, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    '''See http://stackoverflow.com/a/5359988/120991
    '''

    from fabric.api import *
    from contextlib import contextmanager

  2. @twneale twneale created this gist Oct 6, 2013.
    23 changes: 23 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    from fabric.api import *
    from contextlib import contextmanager


    env.update(
    use_ssh_config=True,
    directory='/home/ubuntu/projects/thingy',
    activate='source /home/ubuntu/.virtualenvs/thingy/bin/activate',
    )


    @contextmanager
    def virtualenv():
    '''Context manager to activate virtualenv.
    '''
    with cd(env.directory):
    with prefix(env.activate):
    yield


    def supervisor(command, process):
    with virtualenv():
    run('supervisor restart something')