Python fabric.api.shell_env() Examples

The following are 7 code examples of fabric.api.shell_env(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module fabric.api , or try the search function .
Example #1
Source File: buildman.py    From boss with MIT License 6 votes vote down vote up
def build(stage, config):
    '''
    Trigger build script to prepare a build for the given stage.
    '''
    info('Getting the build ready for deployment')

    # Trigger the install script
    runner.run_script_safely(known_scripts.PRE_INSTALL, remote=False)
    runner.run_script_safely(known_scripts.INSTALL, remote=False)
    runner.run_script_safely(known_scripts.POST_INSTALL, remote=False)

    env_vars = get_build_env_vars(stage, config)

    with shell_env(**env_vars):
        runner.run_script_safely(known_scripts.PRE_BUILD, remote=False)
        runner.run_script_safely(known_scripts.BUILD, remote=False)
        runner.run_script_safely(known_scripts.POST_BUILD, remote=False) 
Example #2
Source File: fabfile.py    From pyconapac-2016 with MIT License 6 votes vote down vote up
def deploy(target='dev', sha1=None):
    if sha1 is None:
        # get current working git sha1
        sha1 = local('git rev-parse HEAD', capture=True)
    # server code reset to current working sha1
    home_dir = '/home/pyconkr/{target}.pycon.kr/pyconkr-2016'.format(target=target)

    if target == 'dev':
        python_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016-dev'
    else:
        python_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016'

    with settings(cd(home_dir), shell_env(DJANGO_SETTINGS_MODULE='pyconkr.settings_prod')):
        sudo('git fetch --all -p', user='pyconkr')
        sudo('git reset --hard ' + sha1, user='pyconkr')
        sudo('bower install', user='pyconkr')
        sudo('%s/bin/pip install -r requirements.txt' % python_env, user='pyconkr')
        sudo('%s/bin/python manage.py compilemessages' % python_env, user='pyconkr')
        sudo('%s/bin/python manage.py migrate' % python_env, user='pyconkr')
        sudo('%s/bin/python manage.py collectstatic --noinput' % python_env, user='pyconkr')
        # worker reload
        run('echo r > /var/run/pyconkr-2016-%s.fifo' % target) 
Example #3
Source File: fabfile.py    From pyconapac-2016 with MIT License 6 votes vote down vote up
def flatpages_mig(direction='www'):
    dev_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016-dev/bin/python'
    www_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016/bin/python'
    from_env, to_env = (dev_env, www_env) if direction=='www' else (www_env, dev_env)
    dev_dir = '/home/pyconkr/dev.pycon.kr/pyconkr-2016'
    www_dir = '/home/pyconkr/www.pycon.kr/pyconkr-2016'
    from_dir, to_dir = (dev_dir, www_dir) if direction=='www' else (www_dir, dev_dir)
    with settings(cd(from_dir),
            shell_env(DJANGO_SETTINGS_MODULE='pyconkr.settings_prod')
            ):
        sudo('{python} manage.py dumpdata --indent 2 flatpages -o {fixture_to}'.format(
            fixture_to=os.path.join(to_dir, 'pyconkr', 'fixtures', 'flatpages.json'),
            python=from_env))
    with settings(cd(to_dir),
            shell_env(DJANGO_SETTINGS_MODULE='pyconkr.settings_prod')
            ):
        sudo('{python} manage.py loaddata flatpages'.format(
             python=to_env)) 
Example #4
Source File: fabfile.py    From learning-python with MIT License 5 votes vote down vote up
def deploy():
    env.host_string = config.HOST_STRING
    with cd('/var/www/test'):
        with shell_env(MODE='PRODUCTION'):
            run('git reset --hard HEAD')
            run('git pull')
            run('npm install')
            run('gulp')
            with prefix('source venv/bin/activate'):
                run('pip install -r requirements.txt')
                run('python manage.py db upgrade')
                run('python manage.py build')
            run('supervisorctl restart test') 
Example #5
Source File: fabfile.py    From Flask-Boost with MIT License 5 votes vote down vote up
def deploy():
    env.host_string = config.HOST_STRING
    with cd('/var/www/#{project}'):
        with shell_env(MODE='PRODUCTION'):
            run('git reset --hard HEAD')
            run('git pull')
            run('npm install')
            run('gulp')
            with prefix('source venv/bin/activate'):
                run('pip install -r requirements.txt')
                run('python manage.py db upgrade')
                run('python manage.py build')
            run('supervisorctl restart #{project}') 
Example #6
Source File: fabfile.py    From ifttt with Apache License 2.0 5 votes vote down vote up
def sr(*cmd):
    """
    Sudo Run - Wraps a given command around sudo and runs it as the
    www-data user
    """
    with shell_env(HOME='/srv/ifttt'):
        return sudo(' '.join(cmd), user='www-data') 
Example #7
Source File: fabfile.py    From openprescribing with MIT License 5 votes vote down vote up
def deploy_static():
    bootstrap_environ = {"MAILGUN_WEBHOOK_USER": "foo", "MAILGUN_WEBHOOK_PASS": "foo"}
    with shell_env(**bootstrap_environ):
        with prefix("source .venv/bin/activate"):
            run(
                "cd openprescribing/ && " "python manage.py collectstatic -v0 --noinput"
            )