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