当前位置: 首页>>代码示例>>Python>>正文


Python env.branch方法代码示例

本文整理汇总了Python中fabric.api.env.branch方法的典型用法代码示例。如果您正苦于以下问题:Python env.branch方法的具体用法?Python env.branch怎么用?Python env.branch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fabric.api.env的用法示例。


在下文中一共展示了env.branch方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: deploy_code

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def deploy_code(host_string):
    max_retries = 20
    retries = 0
    log.debug("Waiting for instance to answer on ssh at {}".format(host_string))
    with settings(host_string="ec2-user@" + host_string):
        while True:
            try:
                fabtools.require.git.working_copy('https://github.com/creativecommons/open-ledger.git', branch=env.branch)
                with cd('open-ledger'):
                    run('virtualenv venv --python=python3 -q')
                    run('./venv/bin/pip install -r requirements.txt -q')
                    break
            except NetworkError:
                time.sleep(5)
                retries += 1
                log.debug("Retrying {} of {}...".format(retries, max_retries))
            if retries > max_retries:
                raise LoaderException("Timed out waiting for ssh") 
开发者ID:cc-archive,项目名称:open-ledger,代码行数:20,代码来源:fabfile.py

示例2: checkpoint

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def checkpoint(force_build):
    env.started_at = datetime.utcnow()
    with settings(warn_only=True):
        inited = run("git status").return_code == 0
        if not inited:
            git_init()
        if run("file .venv").return_code > 0:
            venv_init()
    env.previous_commit = run("git rev-parse --verify HEAD")
    run("git fetch")
    env.next_commit = run("git rev-parse --verify origin/%s" % env.branch)
    env.changed_files = set(
        run(
            "git diff --name-only %s %s" % (env.previous_commit, env.next_commit),
            pty=False,
        ).split()
    )
    if not force_build and env.next_commit == env.previous_commit:
        abort("No changes to pull from origin!") 
开发者ID:ebmdatalab,项目名称:openprescribing,代码行数:21,代码来源:fabfile.py

示例3: deploy

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def deploy(environment, force_build=False, branch="master"):
    setup_env_from_environment(environment)
    env.branch = branch
    setup_sudo()
    with cd(env.path):
        checkpoint(force_build)
        git_pull()
        pip_install()
        npm_install()
        npm_install_deps(force_build)
        npm_build_js()
        npm_build_css(force_build)
        deploy_static()
        run_migrations()
        # build_changed_measures()
        graceful_reload()
        clear_cloudflare()
        setup_cron()
        log_deploy()
        # check_numbers() 
开发者ID:ebmdatalab,项目名称:openprescribing,代码行数:22,代码来源:fabfile.py

示例4: prod

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def prod():
    env.site = "prod"
    env.branch = "prod" 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:5,代码来源:fabfile.py

示例5: staging

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def staging():
    env.site = "staging"
    env.branch = "master" 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:5,代码来源:fabfile.py

示例6: push

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def push(remote="origin", branch="master", runlocal=True):
    command = f"git push {remote} {branch}"
    if runlocal:
        local(command)
    else:
        run(command) 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:8,代码来源:fabfile.py

示例7: pull

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def pull(remote="origin", branch="master", runlocal=True):
    if runlocal:
        local(f"git pull --rebase {remote} {branch}")
    else:
        run("git checkout -- locale/*/django.mo")
        run(f"git pull {remote} {branch}") 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:8,代码来源:fabfile.py

示例8: checkout

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def checkout(remote="origin", branch="master", runlocal=True):
    command = f"git checkout {remote}/{branch}"
    if runlocal:
        local(command)
    else:
        run(command) 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:8,代码来源:fabfile.py

示例9: deploy

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def deploy(build_type='prod', skip_git=False):
    """
    Deploy code, pip dependencies and execute migrations
    """
    prepare_build_or_deploy(build_type=build_type)

    if not skip_git:
        with cd('/srv/calthorpe/urbanfootprint/'):
            sudo('git config --global user.name {0}'.format(env.deploy_user))
            sudo('git stash', user=env.deploy_user)
            run_as_user(env.deploy_user, 'git fetch')

            if getattr(env, 'branch', None):
                run_as_user(env.deploy_user, ('git checkout {branch}'.format(branch=env.branch)))

            # There should never be any local commits on hosts that we are deploying to.
            run_as_user(env.deploy_user, 'git pull')
            run_as_user(env.deploy_user, 'git submodule init')
            run_as_user(env.deploy_user, 'git submodule sync')
            run_as_user(env.deploy_user, 'git submodule update --remote')

    commit = get_commit(build_type=build_type)

    with cd(get_django_setting(build_type, 'ROOT_PATH')):
        pip_install(build_type)
        manage_py('migrate --delete-ghost-migrations', build_type)

    build_sproutcore(build_type=build_type)

    with settings(warn_only=True):
        sudo('supervisorctl stop all')
        sudo('/etc/init.d/supervisor stop')
        sudo('/etc/init.d/nginx stop')

    sudo('/etc/init.d/nginx start')
    sudo('/etc/init.d/supervisor start')
    sudo('supervisorctl start all')

    name = getattr(env, 'name', env.host) 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:41,代码来源:methods.py

示例10: clone_source_repo

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def clone_source_repo():
    """
    Clone source repo at SOURCE_DIR
    """
    sr('mkdir', '-p', SOURCE_DIR)
    sr('chmod', '-R', '775', SOURCE_DIR)
    with cd('/'):
        sr('git', 'clone', 'https://github.com/wikimedia/ifttt.git',
           SOURCE_DIR)
    with cd(SOURCE_DIR):
        sr('git', 'checkout', env.branch) 
开发者ID:wikimedia,项目名称:ifttt,代码行数:13,代码来源:fabfile.py

示例11: update_source_repo

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def update_source_repo():
    """
    Update the ifttt source repo
    """
    print 'Updating ifttt source repo'
    with cd(SOURCE_DIR):
        sr('git', 'fetch', 'origin', env.branch)
        sr('git', 'reset', '--hard', 'FETCH_HEAD') 
开发者ID:wikimedia,项目名称:ifttt,代码行数:10,代码来源:fabfile.py

示例12: git_init

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def git_init():
    run(
        "git init . && "
        "git remote add origin "
        "https://github.com/ebmdatalab/openprescribing.git && "
        "git fetch origin && "
        "git branch --set-upstream master origin/master"
    ) 
开发者ID:ebmdatalab,项目名称:openprescribing,代码行数:10,代码来源:fabfile.py

示例13: git_pull

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def git_pull():
    run("git fetch --all")
    run("git checkout --force origin/%s" % env.branch) 
开发者ID:ebmdatalab,项目名称:openprescribing,代码行数:5,代码来源:fabfile.py

示例14: build_changed_measures

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import branch [as 别名]
def build_changed_measures():
    """For any measures changed since the last deploy, run
    `import_measures`.
    """
    measures = []
    if env.environment == "production":
        # Production deploys are always one-off operations of tested
        # branches, so we can just check all the newly-changed files
        changed_files = env.changed_files
    else:
        # In staging, we often incrementally add commits and
        # re-test. In this case, we should rebuild all the changed
        # measures every time, because some of them may have failed to
        # have been built.

        # Git magic taken from https://stackoverflow.com/a/4991675/559140
        # finds the start of the current branch
        changed_files = run(
            "git diff --name-only "
            "$(diff --old-line-format='' --new-line-format='' "
            '<(git rev-list --first-parent "${1:-master}") '
            '<(git rev-list --first-parent "${2:-HEAD}") | head -1)',
            pty=False,
        ).splitlines()

    for f in changed_files:
        if "commands/measure_definitions" in f:
            measures.append(os.path.splitext(os.path.basename(f))[0])
    if measures:
        measures = ",".join(measures)
        print("Rebuilding measures {}".format(measures))
        build_measures(environment=env.environment, measures=measures) 
开发者ID:ebmdatalab,项目名称:openprescribing,代码行数:34,代码来源:fabfile.py


注:本文中的fabric.api.env.branch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。