當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。