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


Python colors.blue方法代码示例

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


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

示例1: _setup_release

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def _setup_release(keep_days=0, full_cluster=True):
    """
    Setup a release in the releases directory with the most recent code.
    Useful for running management commands. These releases will automatically
    be cleaned up at the finish of each deploy. To ensure that a release will
    last past a deploy use the `keep_days` param.

    :param keep_days: The number of days to keep this release before it will be purged
    :param full_cluster: If False, only setup on webworkers[0] where the command will be run
    """
    deploy_ref = env.deploy_metadata.deploy_ref  # Make sure we have a valid commit
    if env.full_deploy:
        env.deploy_metadata.tag_setup_release()
    execute_with_timing(release.create_code_dir(full_cluster))
    execute_with_timing(release.update_code(full_cluster), deploy_ref)
    execute_with_timing(release.update_virtualenv(full_cluster))

    execute_with_timing(copy_release_files, full_cluster)

    if keep_days > 0:
        execute_with_timing(release.mark_keep_until(full_cluster), keep_days)

    print(blue("Your private release is located here: "))
    print(blue(env.code_root)) 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:26,代码来源:fabfile.py

示例2: choose_hosts

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def choose_hosts():
    """
    Select the hosts to be used.
    """
    global selected_hosts
    mylist = map(lambda (num, h): [num, h], enumerate(env.hosts))
    print(fab_col.blue("Select Hosts (space-separated):"))
    print(fab_col.blue(tabulate(mylist, ["Number", "Host"])))
    choices = raw_input("> ").split()
    # Avoid letters in string index
    choices = filter(lambda x: x.isdigit(), choices)
    # Convert to int list
    choices = map(int, choices)
    # Avoid IndexError
    choices = filter(lambda x: x < len(env.hosts), choices)
    # Remove duplicates
    choices = list(set(choices))
    # If no hosts are selected, keep the current hosts
    if len(choices) == 0:
        return
    # Get only selected hosts
    selected_hosts = map(lambda i: env.hosts[i], choices) 
开发者ID:marcorosa,项目名称:CnC-Botnet-in-Python,代码行数:24,代码来源:fabfile.py

示例3: fix_solr

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def fix_solr():
    """ Fix solr
        work in progress
    """
    with cd('/var/tmp'):
        print blue('pulling new code...')
        sudo('/etc/init.d/jetty stop')
        sleep(5)
        # run('rm -rf /opt/deploy/solr/collection1')

        print blue('copying new code...')
        # run('mkdir -p /opt/deploy/solr/collection1')
        # run("cp -r oclapi/solr/collection1/conf /opt/deploy/solr/collection1")

    with cd("/opt/deploy/ocl_api/ocl"):
        # there is no need for this, settings.py.eploy is actually wrong?
        # run("cp settings.py.deploy settings.py")
        with prefix('source /opt/virtualenvs/ocl_api/bin/activate'):
            with prefix('export DJANGO_CONFIGURATION="Production"'):
                with prefix('export DJANGO_SECRET_KEY="blah"'):
                    # this is really slow because it pull down django-norel
                    run('./manage.py build_solr_schema > ' +
                        '/opt/deploy/solr/collection1/conf/schema.xml')
    sleep(5)
    sudo('/etc/init.d/jetty start') 
开发者ID:OpenConceptLab,项目名称:ocl_web,代码行数:27,代码来源:fabfile.py

示例4: createdb

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def createdb(database_name, database_user, get_password):
    if confirm(colors.red(
        "Show DB Password? You should only run this when others aren't looking over your shoulder. Run the command?")):
        print((colors.blue("Password: ") + colors.yellow(get_password())))
    if confirm(colors.red("This will overwrite local data, are you sure?")):
        UbuntuPgCreateDbAndUser(database_name, database_user)()


# ------------------------------------------------------------------------------- 
开发者ID:cyanfish,项目名称:heltour,代码行数:11,代码来源:strabulous.py

示例5: latest_live_db

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def latest_live_db(live_backup_script_path, live_latest_sql_file_path, database_name, database_user,
                   get_password):
    if confirm(colors.red("This will overwrite local data, are you sure?")):
        if confirm(colors.red("Create a new backup?")):
            run(live_backup_script_path)
        local_target = project_relative("data/latestdb.sql.bz2")
        if confirm(colors.red("Download New backup?")):
            local_db = get(live_latest_sql_file_path, local_target)[0]
        else:
            local_db = local_target
        with settings(warn_only=True):
            if confirm(colors.red(
                "Show password? You should only run this when others aren't looking over your shoulder. Show database password?")):
                print((colors.blue("Password: ") + colors.yellow(get_password())))
            PgLoadPlain(local_db, database_name, database_user)() 
开发者ID:cyanfish,项目名称:heltour,代码行数:17,代码来源:strabulous.py

示例6: prepare_files

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def prepare_files():
    hq_dir = '{}/commcare-hq'.format(OFFLINE_STAGING_DIR)

    if not os.path.isdir(hq_dir):
        local(
            'git clone --recursive https://github.com/dimagi/commcare-hq.git {}'
            .format(hq_dir)
        )
    else:
        print(blue('Skipping clone stage because {} already exists'.format(hq_dir)))

    # Let's create bower and npm zip files

    yarn_lock = os.path.join(env.code_root, YARN_LOCK)

    # Bower
    if not files.exists(yarn_lock):
        local('cd {}/commcare-hq && {}'.format(OFFLINE_STAGING_DIR, generate_bower_command('install', {
            'interactive': 'false',
        })))

    # NPM or Yarn
    local('cd {}/commcare-hq'.format(OFFLINE_STAGING_DIR))
    if files.exists(yarn_lock):
        local('yarn install --production')
    else:
        local('npm install --production')

    prepare_pip_wheels(os.path.join('requirements', 'requirements.txt'))
    prepare_pip_wheels(os.path.join('requirements', 'prod-requirements.txt')) 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:32,代码来源:offline.py

示例7: _print_stats

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def _print_stats(filename):
    try:
        stat = os.stat(filename)
    except OSError:
        print(red('Not found {}'.format(filename)))
        print(red('Exiting.'))
        exit()

    last_modified = str(datetime.fromtimestamp(stat.st_mtime))
    print(blue('Found {}, last modifed: {}'.format(filename, last_modified))) 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:12,代码来源:offline.py

示例8: deploy_checkpoint

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def deploy_checkpoint(command_index, command_name, fn, *args, **kwargs):
    """
    Stores fabric env in redis and then runs the function if it shouldn't be skipped
    """
    if env.resume and command_index < env.checkpoint_index:
        print(blue("Skipping command: '{}'".format(command_name)))
        return
    cache_deploy_state(command_index)
    fn(*args, **kwargs) 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:11,代码来源:fabfile.py

示例9: rollback

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def rollback():
    """
    Rolls back the servers to the previous release if it exists and is same
    across servers.
    """
    number_of_releases = execute(release.get_number_of_releases)
    if not all(n > 1 for n in number_of_releases):
        print(red('Aborting because there are not enough previous releases.'))
        exit()

    releases = execute(release.get_previous_release)

    unique_releases = set(releases.values())
    if len(unique_releases) != 1:
        print(red('Aborting because not all hosts would rollback to same release'))
        exit()

    unique_release = unique_releases.pop()

    if not unique_release:
        print(red('Aborting because release path is empty. '
                  'This probably means there are no releases to rollback to.'))
        exit()

    if not console.confirm('Do you wish to rollback to release: {}'.format(unique_release), default=False):
        print(blue('Exiting.'))
        exit()

    exists = execute(release.ensure_release_exists, unique_release)

    if all(exists.values()):
        print(blue('Updating current and restarting services'))
        execute(release.update_current, unique_release)
        silent_services_restart(use_current_release=True)
        execute(release.mark_last_release_unsuccessful)
    else:
        print(red('Aborting because not all hosts have release'))
        exit() 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:40,代码来源:fabfile.py

示例10: print_command

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def print_command(command):
    _print(blue("$ ", bold=True) +
           yellow(command, bold=True) +
           red(" ->", bold=True)) 
开发者ID:keithadavidson,项目名称:ansible-mezzanine,代码行数:6,代码来源:fabfile.py

示例11: open_sh

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def open_sh():
    """
    Open a shell on a host.
    """
    mylist = map(lambda (num, h): [num, h], enumerate(selected_hosts))
    print(fab_col.blue(tabulate(mylist, ["Number", "Host"])))
    try:
        n = input("Open shell in host number: ")
        h = selected_hosts[n]
        execute(open_shell, host=h)
    except (NameError, IndexError):
        print(fab_col.red("Error: invalid host selection."))
        print(fab_col.red("Shell not opened.")) 
开发者ID:marcorosa,项目名称:CnC-Botnet-in-Python,代码行数:15,代码来源:fabfile.py

示例12: checkout_api_app

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def checkout_api_app(do_pip=False):
    """ Get latest API server software.
        This is normally done as part of release task's git clone.

        This process is different from the web server process because
        it uses a "git cone, then copy the source files to runtime"
        method for the release instead of directly pulling into the
        run time.
    """
    with cd('/var/tmp'):
        print blue('pulling new code...')
        sudo('/etc/init.d/jetty stop')
        run("rm -rf oclapi")
        run("git clone https://github.com/OpenConceptLab/oclapi.git")

        print blue('deleting old code...')
        run('rm -rf /opt/deploy/ocl_api/ocl')
        run('rm -rf /opt/deploy/solr/collection1')

        print blue('copying new code...')
        run("cp -r oclapi/django-nonrel/ocl /opt/deploy/ocl_api")
        run('mkdir -p /opt/deploy/solr/collection1')
        run("cp -r oclapi/solr/collection1/conf /opt/deploy/solr/collection1")

    with cd("/opt/deploy/ocl_api/ocl"):
        # there is no need for this, settings.py.eploy is actually wrong?
        # run("cp settings.py.deploy settings.py")
        with prefix("source /opt/virtualenvs/ocl_api/bin/activate"):
            with prefix('export DJANGO_CONFIGURATION="Production"'):
                with prefix('export DJANGO_SECRET_KEY="blah"'):
                    # this is really slow because it pull down django-norel
                    if do_pip:
                        run("pip install -r requirements.txt")
                    run('./manage.py build_solr_schema > ' +
                        '/opt/deploy/solr/collection1/conf/schema.xml')
    sudo('/etc/init.d/jetty start') 
开发者ID:OpenConceptLab,项目名称:ocl_web,代码行数:38,代码来源:fabfile.py

示例13: _copy_secrets

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def _copy_secrets():
    """
    Copies secrets from local to remote.
    :return:
    """
    secret = ".env.{}".format(ENV.name)

    remote_path = os.path.join(ENV.project_dir, ".env")
    print(blue("Copying {secret} to {remote_path} on {host}".format(
        secret=secret, remote_path=remote_path, host=ENV.host
    )))
    put(secret, remote_path)

    with cd(ENV.project_dir):
        run("echo 'DEPLOYMENT_DATETIME=%s' >> %s" % (ENV.DEPLOYMENT_DATETIME, remote_path)) 
开发者ID:wise-team,项目名称:steemprojects.com,代码行数:17,代码来源:fabfile.py

示例14: deploy

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def deploy():
    print green("Start to Deploy the Project")
    print green("=" * 40)

    # Create directory
    print blue("create the deploy directory")
    print blue("*" * 40)
    mkdir(path=DEPLOY_DIR)
    mkdir(path=LOG_DIR)

    # Get source code
    print blue("get the source code from remote")
    print blue("*" * 40)
    with cd(DEPLOY_DIR):
        with settings(warn_only=True):
            rm(path=PROJECT_DIR)
        run("git clone {}".format(GITHUB_PATH))

    # Install python virtualenv
    print blue("install the virtualenv")
    print blue("*" * 40)
    sudo("apt-get install python-virtualenv")

    # Install nginx
    print blue("install the nginx")
    print blue("*" * 40)
    sudo("apt-get install nginx")
    sudo("cp {}/nginx.conf /etc/nginx/".format(CONFIG_DIR))
    sudo("cp {}/nginx_geekvi.conf /etc/nginx/sites-enabled/".format(CONFIG_DIR))

    # Install python requirements
    with cd(DEPLOY_DIR):
        if not exists(VENV_DIR):
            run("virtualenv {}".format(VENV_DIR))
        with settings(warn_only=True):
            with source_virtualenv():
                sudo("pip install -r {}/requirements.txt".format(PROJECT_DIR))

    # Config supervisor
    sudo("supervisord -c {}/supervisor.conf".format(CONFIG_DIR))
    sudo("supervisorctl -c {}/supervisor.conf reload".format(CONFIG_DIR))
    sudo("supervisorctl -c {}/supervisor.conf status".format(CONFIG_DIR))
    sudo("supervisorctl -c {}/supervisor.conf start all".format(CONFIG_DIR)) 
开发者ID:laplace-vi,项目名称:React-News-Board,代码行数:45,代码来源:fabfile.py

示例15: main

# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import blue [as 别名]
def main(args):
    with open(args.pk_file1, 'rb') as fin:
        hyps1 = pickle.load(fin)
        refs = pickle.load(fin)
        pickle.load(fin)  # hypscores
        pickle.load(fin)  # refscores
        numphones = pickle.load(fin)
    with open(args.pk_file2, 'rb') as fin:
        hyps2 = pickle.load(fin)
    assert len(hyps1) == len(hyps2), 'hyps have different lengths'

    differ = difflib.Differ()

    num_diff = 0
    hyp1_better = 0
    hyp2_better = 0
    for (hyp1, hyp2, ref) in zip(hyps1, hyps2, refs):
        if hyp1 == hyp2:
            continue
        num_diff += 1

        label1 = 'hyp1:'
        label2 = 'hyp2:'

        if args.score:
            dist1, _, _, _, _ = ed.edit_distance(ref, hyp1)
            dist2, _, _, _, _ = ed.edit_distance(ref, hyp2)
            if dist1 < dist2:
                hyp1_better += 1
                label1 = blue(label1)
                label2 = red(label2)
            else:
                hyp2_better += 1
                label1 = red(label1)
                label2 = blue(label2)

        print label1, collapse_seq(hyp1)
        print label2, collapse_seq(hyp2)
        pprint(list(differ.compare([collapse_seq(hyp1)], [collapse_seq(hyp2)])))
        print green(' ref:'), collapse_seq(ref)
        print '-' * 80

    if args.score:
        print 'hyp1 better: %d' % hyp1_better
        print 'hyp2 better: %d' % hyp2_better
    print 'Differ on %d/%d utts' % (num_diff, len(refs)) 
开发者ID:amaas,项目名称:stanford-ctc,代码行数:48,代码来源:compareHyps.py


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