Python fabric.api 模块,prefix() 实例源码

我们从Python开源项目中,提取了以下35个代码示例,用于说明如何使用fabric.api.prefix()

项目:gloss    作者:openhealthcare    | 项目源码 | 文件源码
def deploy_test(key_file_name="../ec2.pem"):
    env.key_filename = key_file_name
    changes = local("git status --porcelain", capture=True)
    if len(changes):
        print " {}".format(changes)
        proceed = prompt(
            "you have uncommited changes, do you want to proceed",
            default=False,
            validate=bool
        )

        if not proceed:
            return

    git_branch_name = local('git rev-parse --abbrev-ref HEAD', capture=True)
    with prefix(". /usr/share/virtualenvwrapper/virtualenvwrapper.sh"):
        with prefix("workon {}".format(virtual_env_name)):
            run("git pull origin {}".format(git_branch_name))
            run("pip install -r requirements.txt")
            run("alembic upgrade head")
            run("pkill twistd||true")
            run("pkill gloss||true")
            run("twistd multiple_mllp --receiver gloss.ohc_receiver.OhcReceiver")
            run("gunicorn -w 1 -b 0.0.0:6767 -D gloss.api:app")
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def update(version=None):
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    if version:
        # try specified version first
        to_version = version
    elif not version and env.srvr in ['local', 'vagrant', 'dev']:
        # if local, vagrant or dev deploy to develop branch
        to_version = 'develop'
    else:
        # else deploy to master branch
        to_version = 'master'

    with cd(env.path), prefix(env.within_virtualenv):
        run('git pull')
        run('git checkout {}'.format(to_version))
项目:spacy-dev-resources    作者:explosion    | 项目源码 | 文件源码
def prebuild(build_dir='/tmp/build_spacy'):
    if file_exists(build_dir):
        shutil.rmtree(build_dir)
    os.mkdir(build_dir)
    spacy_dir = path.dirname(__file__)
    wn_url = 'http://wordnetcode.princeton.edu/3.0/WordNet-3.0.tar.gz'
    build_venv = path.join(build_dir, '.env')
    with lcd(build_dir):
        local('git clone %s .' % spacy_dir)
        local('virtualenv ' + build_venv)
        with prefix('cd %s && PYTHONPATH=`pwd` && . %s/bin/activate' % (build_dir, build_venv)):
            local('pip install cython fabric fabtools pytest')
            local('pip install --no-cache-dir -r requirements.txt')
            local('fab clean make')
            local('cp -r %s/corpora/en/wordnet corpora/en/' % spacy_dir)
            local('PYTHONPATH=`pwd` python bin/init_model.py en lang_data corpora spacy/en/data')
            local('PYTHONPATH=`pwd` fab test')
            local('PYTHONPATH=`pwd` python -m spacy.en.download --force all')
            local('PYTHONPATH=`pwd` py.test --models spacy/tests/')
项目:stregsystemet    作者:f-klubben    | 项目源码 | 文件源码
def deploy():
    with cd("/data/stregsystem"):
        sudo("systemctl stop apache2.service")
        with settings(sudo_user='stregsystem'):
            sudo("git pull --ff-only")
            with prefix("source /data/stregsystem/env/bin/activate"):
                sudo("pip install -rrequirements.txt")
                sudo("python manage.py collectstatic --noinput")
                sudo("python manage.py migrate")
        sudo("systemctl start apache2.service")
项目:meetup-facebook-bot    作者:Stark-Mountain    | 项目源码 | 文件源码
def install_modules():
    requirements_path = os.path.join(PROJECT_FOLDER, 'requirements.txt')
    venv_activate_path = os.path.join(VENV_BIN_DIRECTORY, 'activate')
    with prefix('source %s' % venv_activate_path):
        sudo('pip install wheel')
        sudo('pip install -r %s' % requirements_path)
项目:meetup-facebook-bot    作者:Stark-Mountain    | 项目源码 | 文件源码
def run_setup_script(script_name, context):
    venv_activate_path = os.path.join(VENV_BIN_DIRECTORY, 'activate')
    venv_activate_command = 'source %s' % venv_activate_path
    with cd(PROJECT_FOLDER), shell_env(**context), prefix(venv_activate_command):
        run('python3 %s' % os.path.join(PROJECT_FOLDER, script_name))
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def makemigrations(app=None):
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    if env.srvr in ['dev', 'stg', 'liv']:
        print(yellow('Do not run makemigrations on the servers'))
        return

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py makemigrations {}'.format(app if app else ''))
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def migrate(app=None):
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py migrate {}'.format(app if app else ''))
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def update_index():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py build_solr_schema > schema.xml')
        run('mv schema.xml ../../solr/collection1/conf/')
        sudo('service tomcat7-{} restart'.format(env.srvr))
        run('./manage.py update_index')
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def clear_cache():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py clear_cache')
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def install_requirements():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    reqs = 'requirements-{}.txt'.format(env.srvr)

    try:
        assert os.path.exists(reqs)
    except AssertionError:
        reqs = 'requirements.txt'

    with cd(env.path), prefix(env.within_virtualenv):
        run('pip install -U -r {}'.format(reqs))
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def reinstall_requirement(which):
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    with cd(env.path), prefix(env.within_virtualenv):
        run('pip uninstall {0} && pip install --no-deps {0}'.format(which))
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def touch_wsgi():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    with cd(os.path.join(env.path, 'dprr')), prefix(env.within_virtualenv):
        run('touch wsgi.py')
项目:dprr-django    作者:kingsdigitallab    | 项目源码 | 文件源码
def runserver(port='8000'):
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    if env.srvr not in ['local', 'vagrant']:
        print(yellow('this server only runs for development purposes'))
        return

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py runserver 0.0.0.0:{}'.format(port))
项目:eshop    作者:djangogirlstaipei    | 项目源码 | 文件源码
def install_requirements():
    with prefix('source {}/venv/bin/activate'.format(PROJECT_DIR)):
        run('pip install -r {}'.format(
            os.path.join(PROJECT_DIR, 'requirements.txt')
        ))
项目:eshop    作者:djangogirlstaipei    | 项目源码 | 文件源码
def manage(command=""):
    with prefix('source {0}venv/bin/activate && export DATABASE_URL={1}'.format(PROJECT_DIR, DATABASE_URL)):
        with cd(DJANGO_DIR):
            run('python manage.py {0}'.format(command))
项目:combine    作者:llllllllll    | 项目源码 | 文件源码
def venv(name):
    return prefix('source /venvs/%s/bin/activate' % name)
项目:cookiecutter-saas    作者:jayfk    | 项目源码 | 文件源码
def docker_machine(machine):
    """
    Sets the environment to use a given docker machine.
    """
    _env = local('docker-machine env {}'.format(machine), capture=True)
    # Reorganize into a string that could be used with prefix().
    _env = re.sub(r'^#.*$', '', _env, flags=re.MULTILINE)  # Remove comments
    _env = re.sub(r'^export ', '', _env, flags=re.MULTILINE)  # Remove `export `
    _env = re.sub(r'\n', ' ', _env, flags=re.MULTILINE)  # Merge to a single line
    return _env
项目:cookiecutter-saas    作者:jayfk    | 项目源码 | 文件源码
def docker_compose(command):
    """
    Run a docker-compose command
    :param command: Command you want to run
    """
    if(env.machine):
        with prefix(docker_machine(env.machine)):
            return local(
                "docker-compose -f {file} {command}".format(
                    file=env.compose_file, command=command)
            )
    return local(
        "docker-compose -f {file} {command}".format(
            file=env.compose_file, command=command)
    )
项目:django_ecommerce    作者:rick-ey    | 项目源码 | 文件源码
def update_app():
    with cd("/opt/mec_env/mec_app"):
        run("git pull")
    with cd("/opt/mec_env/mec_app/django_ecommerce"):
        with prefix("source /opt/mec_env/bin/activate"):
            run("pip install -r ../requirements.txt")
            run("./manage.py migrate --noinput")
            run("./manage.py collectstatic --noinput")
项目:fieldsight-kobocat    作者:awemulya    | 项目源码 | 文件源码
def kobo_workon(_virtualenv_name):
    return prefix('kobo_workon %s' % _virtualenv_name)
项目:django-repsystem    作者:9dev    | 项目源码 | 文件源码
def _venv_local():
    with shell_env(DJANGO_SETTINGS_MODULE=SETTINGS_MODULE):
        with prefix('. %s/bin/activate' % VENV_PATH):
            yield
项目:automatic-repo    作者:WZQ1397    | 项目源码 | 文件源码
def env_set():
    with path('/opt/'):
        run('echo $PATH')
    run('echo $PATH')
    #fixme ALL para you can use http://docs.fabfile.org/en/1.13/usage/env.html
    with settings(warn_only=True):
        run('echo $USER')
    with prefix('free'):
        with shell_env(JAVA_HOME='/opt/java'):
            run('echo $JAVA_HOME')
项目:crestify    作者:crestify    | 项目源码 | 文件源码
def config_environment():
    sudo('apt-get -y install git screen')
    sudo('adduser crestify --disabled-password --gecos GECOS')
    sudo('locale-gen en_US.UTF-8')
    with settings(sudo_user='crestify', shell='/bin/bash -c'):
        with cd('/home/crestify'):
            sudo('git clone https://github.com/crestify/crestify.git crestify')
            sudo('virtualenv crestifyenv')
            with prefix('source crestifyenv/bin/activate'):
                sudo('pip install -r crestify/requirements.txt')
项目:crestify    作者:crestify    | 项目源码 | 文件源码
def run_migrations():
    with settings(sudo_user='crestify', shell='/bin/bash -c'):
        with cd('/home/crestify/crestify'):
            with prefix('source ../crestifyenv/bin/activate'):
                sudo('honcho run python main.py db upgrade')  # Run initial migrations
项目:crestify    作者:crestify    | 项目源码 | 文件源码
def _git_update():
    with settings(sudo_user="crestify", shell='/bin/bash -c'):
        with cd('/home/crestify/crestify'):
            with prefix('source ../crestifyenv/bin/activate'):
                with settings(sudo_user='crestify', shell='/bin/bash -c'):
                    sudo('git pull')
                    sudo('pip install -r requirements.txt')
                    sudo('honcho run python main.py db upgrade')
项目:fapistrano    作者:liwushuo    | 项目源码 | 文件源码
def _upgrade_pip():
    with prefix(env.virtualenv_activate):
        run('pip install -U pip setuptools wheel')
项目:fapistrano    作者:liwushuo    | 项目源码 | 文件源码
def _install_requirements():
    with prefix(env.virtualenv_activate):
        run('pip install -r %(virtualenv_requirements)s' % env)
项目:fapistrano    作者:liwushuo    | 项目源码 | 文件源码
def _upgrade_pip():
    with prefix(env.virtualenvwrapper_activate):
        run('pip install -q -U pip setuptools wheel || pip install -U pip setuptools wheel')
项目:fapistrano    作者:liwushuo    | 项目源码 | 文件源码
def _install_requirements():
    with prefix(env.virtualenvwrapper_activate):
        run('pip install -r %(virtualenvwrapper_requirements)s' % env)
项目:startupintro    作者:ShubhamBansal1997    | 项目源码 | 文件源码
def virtualenv():
    """Activates virtualenv context for other commands to run inside it.
    """
    with fab.cd(HERE):
        with fab.prefix('source %(virtualenv_dir)s/bin/activate' % env):
            yield
项目:FormShare    作者:qlands    | 项目源码 | 文件源码
def source(path):
    return prefix('source %s' % path)
项目:FormShare    作者:qlands    | 项目源码 | 文件源码
def deploy_template(env):
    if env.get('template'):
        run("git remote add template %s || true" % env.template)
        run("git fetch template")
        run("git reset HEAD %s && rm -rf %s" % (env.template_dir,
                                                env.template_dir))
        run("git read-tree --prefix=%s -u template/master"
            % env.template_dir)
项目:perdiem-django    作者:RevolutionTech    | 项目源码 | 文件源码
def deploy():
    with prefix(". /usr/local/bin/virtualenvwrapper.sh; workon perdiem"):
        previous_commit_hash = run("git log -1 --format=\"%H\" --no-color", pty=False)
        run("git pull")
        cmd_changes_deployed = "git log {previous_hash}.. --reverse --format=\"%h : %an : %s\" --no-color".format(
            previous_hash=previous_commit_hash
        )
        changes_deployed = run(cmd_changes_deployed, pty=False)
        run("pip install -r ../requirements.txt")
        run("python manage.py migrate")
        run("python manage.py collectstatic --no-input")
        sudo("sv restart perdiem")
    send_notification(changes_deployed)
项目:cookiecutter-flask-seed-minimal    作者:hypebeast    | 项目源码 | 文件源码
def install_dist_package():
    """Install the dist package on the remote host(s)."""
    with cd(remote_app_dir):
        with prefix(env.activate):
            sudo('pip install {}'.format(dist_package_file))

    # remove dist package
    run('rm {}'.format(dist_package_file))

# END DEPLOYMENT HELPERS


# Supervisor