當前位置: 首頁>>代碼示例>>Python>>正文


Python console.confirm方法代碼示例

本文整理匯總了Python中fabric.contrib.console.confirm方法的典型用法代碼示例。如果您正苦於以下問題:Python console.confirm方法的具體用法?Python console.confirm怎麽用?Python console.confirm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fabric.contrib.console的用法示例。


在下文中一共展示了console.confirm方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: rollback_formplayer

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def rollback_formplayer():
    build_dir = os.path.join(env.code_current, FORMPLAYER_BUILD_DIR)

    builds = _get_old_formplayer_builds(build_dir)
    if not builds:
        utils.abort('No formplayer builds to rollback to.')

    rollback_build = builds[0]
    if not console.confirm('Confirm rollback to "{}"'.format(rollback_build), default=False):
        utils.abort('Action aborted.')

    with cd(build_dir):
        sudo('ln -sfn {build_dir}/{rollback} {build_dir}/current'.format(
            build_dir=build_dir,
            rollback=rollback_build
        )) 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:18,代碼來源:formplayer.py

示例2: _confirm_environment_time

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def _confirm_environment_time(env_name):
    window = env.acceptable_maintenance_window
    if window:
        d = datetime.datetime.now(pytz.timezone(window['timezone']))
        if window['hour_start'] <= d.hour < window['hour_end']:
            return
    else:
        return

    message = (
        "Whoa there bud! You're deploying '%s' during the day. "
        "The current local time is %s.\n"
        "ARE YOU DOING SOMETHING EXCEPTIONAL THAT WARRANTS THIS?"
    ) % (env_name, d.strftime("%-I:%M%p on %h. %d %Z"))
    if not console.confirm(message, default=False):
        utils.abort('Action aborted.') 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:18,代碼來源:fabfile.py

示例3: add_host

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def add_host():
    """
    Add a new host to the running hosts.
    The user can decide whether to add the host also to the external hosts.txt
    file.
    """
    name = raw_input("Username: ")
    host = raw_input("Host: ")
    port = input("Port: ")
    new_host = name + "@" + host + ":" + str(port)
    selected_hosts.append(new_host)
    password = None
    if confirm("Authenticate using a password? "):
        password = getpass.getpass("Password: ").strip()
        env.passwords[new_host] = password

    # Append the new host to the hosts file
    if confirm("Add the new host to the hosts file? "):
        if password is not None:
            line = new_host + " " + password + "\n"
        else:
            line = new_host + "\n"
        with open(file_hosts, 'a') as f:
            f.write(line) 
開發者ID:marcorosa,項目名稱:CnC-Botnet-in-Python,代碼行數:26,代碼來源:fabfile.py

示例4: __init__

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def __init__(self, callback, color=colors.yellow, title=None):
        super(Infrastructure, self).__init__()

        # We need to be sure that `default()` will be at first place
        # every time when vars(self) is being invoked.
        # This is necessary to exclude `default` from the list of task
        # because of it's already there as default task.
        # See `fabric.main.extract_tasks()` for details
        self.__dict__ = utils.PriorityDict(self.__dict__, priority=['default'])

        default, confirm = self.default, self.confirm

        self.callback = callback
        self.name = getattr(callback, '__name__', self.name)
        self.title = color(title or self.name)
        self.__doc__ = (self.__doc__ or '').format(**self.__dict__)
        default.__doc__ = (default.__doc__ or '').format(**self.__dict__)
        confirm.__doc__ = (confirm.__doc__ or '').format(**self.__dict__)

        # enable "module" behaviour in task mode
        self.use_task_objects = not is_task_mode() 
開發者ID:renskiy,項目名稱:fabricio,代碼行數:23,代碼來源:tasks.py

示例5: restore_remote

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def restore_remote():
    warning = "WARNING: You are about to overwrite your LOCAL database. Continue?"
    if not console.confirm(warning, default=False):
        return

    _db_kill_sessions()

    # drop/create database
    local("dropdb {}".format(APP_NAME))
    local("createdb {} -O {}".format(APP_NAME, APP_NAME))

    # restore latest remote dump
    last_backup = _sorted_ls(LOCAL_BACKUPS_DIR)[-1]
    local("pg_restore backups/{} -d {} --no-owner -x -n public --role={}"
          .format(last_backup, APP_NAME, APP_NAME))

    _db_size_report() 
開發者ID:johnwheeler,項目名稱:flask-live-starter,代碼行數:19,代碼來源:local.py

示例6: deploylive

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def deploylive():
    manage_py = project_relative("manage.py")
    local("rm -r static")
    local("mkdir static")
    local("python %s compilestatic" % manage_py)
    local("python %s collectstatic --noinput" % manage_py)
    if confirm(colors.red(
        "This will deploy to the live server (LIVE ENV) and restart the server. Are you sure?")):
        remote_directory = "/home/lichess4545/web/www.lichess4545.com"
        local_directory = project_relative(".") + "/"
        RsyncDeployment(
            remote_directory,
            local_directory
        )(
            exclude=['env', 'data', 'lichess4545@marta.lichess.ovh', 'certs']
        )
        run(
            "echo \"/home/lichess4545/web/www.lichess4545.com/current/\" > /home/lichess4545/web/www.lichess4545.com/env/lib/python3.6/site-packages/heltour.pth")

        if confirm(colors.red("Would you like to update the dependencies?")):
            run(
                "/home/lichess4545/web/www.lichess4545.com/current/sysadmin/update-requirements-live.sh")
        if confirm(colors.red("Would you like to run the migrations?")):
            run("/home/lichess4545/web/www.lichess4545.com/current/sysadmin/migrate-live.sh")
        if confirm(colors.red("Would you like to invalidate the caches?")):
            run("/home/lichess4545/web/www.lichess4545.com/current/sysadmin/invalidate-live.sh")

        if confirm(colors.red("Would you like to restart the server?")):
            sudo("/usr/sbin/service heltour-live restart", shell=False)
            sudo("/usr/sbin/service heltour-live-api restart", shell=False)
            sudo("/usr/sbin/service heltour-live-celery restart", shell=False)

        if confirm(colors.red("Would you like to reload nginx?")):
            sudo("/usr/sbin/service nginx reload", shell=False)


# ------------------------------------------------------------------------------- 
開發者ID:cyanfish,項目名稱:heltour,代碼行數:39,代碼來源:fabfile.py

示例7: deploystaging

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def deploystaging():
    manage_py = project_relative("manage_staging.py")
    local("rm -r static")
    local("mkdir static")
    local("python %s compilestatic" % manage_py)
    local("python %s collectstatic --noinput" % manage_py)
    if confirm(colors.red(
        "This will deploy to the live server (STAGING ENV) and restart the server. Are you sure?")):
        remote_directory = "/home/lichess4545/web/staging.lichess4545.com"
        local_directory = project_relative(".") + "/"
        RsyncDeployment(
            remote_directory,
            local_directory
        )(
            exclude=['env', 'data', 'lichess4545@marta.lichess.ovh', 'certs']
        )
        run(
            "echo \"/home/lichess4545/web/staging.lichess4545.com/current/\" > /home/lichess4545/web/staging.lichess4545.com/env/lib/python3.6/site-packages/heltour.pth")

        if confirm(colors.red("Would you like to update the dependencies?")):
            run(
                "/home/lichess4545/web/staging.lichess4545.com/current/sysadmin/update-requirements-staging.sh")
        if confirm(colors.red("Would you like to run the migrations?")):
            run("/home/lichess4545/web/staging.lichess4545.com/current/sysadmin/migrate-staging.sh")
        if confirm(colors.red("Would you like to invalidate the caches?")):
            run(
                "/home/lichess4545/web/staging.lichess4545.com/current/sysadmin/invalidate-staging.sh")

        if confirm(colors.red("Would you like to restart the server?")):
            sudo("/usr/sbin/service heltour-staging restart", shell=False)
            sudo("/usr/sbin/service heltour-staging-api restart", shell=False)
            sudo("/usr/sbin/service heltour-staging-celery restart", shell=False)

        if confirm(colors.red("Would you like to reload nginx?")):
            sudo("/usr/sbin/service nginx reload", shell=False)


# ------------------------------------------------------------------------------- 
開發者ID:cyanfish,項目名稱:heltour,代碼行數:40,代碼來源:fabfile.py

示例8: restartlive

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def restartlive():
    if confirm(colors.red("Would you like to invalidate the caches?")):
        run("/home/lichess4545/web/www.lichess4545.com/current/sysadmin/invalidate-live.sh")

    if confirm(colors.red("Would you like to restart the server?")):
        sudo("/usr/sbin/service heltour-live restart", shell=False)
        sudo("/usr/sbin/service heltour-live-api restart", shell=False)
        sudo("/usr/sbin/service heltour-live-celery restart", shell=False)


# ------------------------------------------------------------------------------- 
開發者ID:cyanfish,項目名稱:heltour,代碼行數:13,代碼來源:fabfile.py

示例9: restartstaging

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def restartstaging():
    if confirm(colors.red("Would you like to invalidate the caches?")):
        run("/home/lichess4545/web/staging.lichess4545.com/current/sysadmin/invalidate-staging.sh")

    if confirm(colors.red("Would you like to restart the server?")):
        sudo("/usr/sbin/service heltour-staging restart", shell=False)
        sudo("/usr/sbin/service heltour-staging-api restart", shell=False)
        sudo("/usr/sbin/service heltour-staging-celery restart", shell=False)


# ------------------------------------------------------------------------------- 
開發者ID:cyanfish,項目名稱:heltour,代碼行數:13,代碼來源:fabfile.py

示例10: restartchesster

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def restartchesster():
    if confirm(colors.red("Would you like to restart chesster?")):
        sudo("/usr/sbin/service chesster restart", shell=False)


# ------------------------------------------------------------------------------- 
開發者ID:cyanfish,項目名稱:heltour,代碼行數:8,代碼來源:fabfile.py

示例11: latest_live_media

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def latest_live_media(live_media_path, local_media_path, password_file_name, live_ssh_username,
                      live_domain):
    local_dir = local_media_path
    remote_dir = live_media_path
    if confirm(colors.red("This will overwrite local data, are you sure?")):
        RsyncMedia(
            '%s@%s' % (live_ssh_username, live_domain),
            remote_directory=remote_dir,
            local_directory=local_dir
        )()


# ------------------------------------------------------------------------------- 
開發者ID:cyanfish,項目名稱:heltour,代碼行數:15,代碼來源:strabulous.py

示例12: latest_live_db

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [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

示例13: _confirm_deploying_same_code

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def _confirm_deploying_same_code():
    if env.deploy_metadata.current_ref_is_different_than_last:
        return

    if env.code_branch == 'master':
        branch_specific_msg = "Perhaps you meant to merge a PR or specify a --set code_branch=<branch> ?"
    elif env.code_branch == 'enterprise':
        branch_specific_msg = (
            "Have you tried rebuilding the enterprise branch (in HQ directory)? "
            "./scripts/rebuildstaging --enterprise"
        )
    elif env.code_branch == 'autostaging':
        branch_specific_msg = (
            "Have you tried rebuilding the autostaging branch (in HQ directory)? "
            "./scripts/rebuildstaging"
        )
    else:
        branch_specific_msg = (
            "Did you specify the correct branch using --set code_branch=<branch> ?"
        )

    message = (
        "Whoa there bud! You're deploying {code_branch} which happens to be "
        "the same code as was previously deployed to this environment.\n"
        "{branch_specific_msg}\n"
        "Is this intentional?"
    ).format(code_branch=env.code_branch, branch_specific_msg=branch_specific_msg)
    if not console.confirm(message, default=False):
        utils.abort('Action aborted.') 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:31,代碼來源:fabfile.py

示例14: _confirm_translated

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def _confirm_translated():
    if datetime.datetime.now().isoweekday() != 3 or env.deploy_env != 'production':
        return True
    return console.confirm(
        "It's the weekly Wednesday deploy, did you update the translations from transifex? "
        "Try running this handy script from the root of your commcare-hq directory:\n./scripts/update-translations.sh\n"
    ) 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:9,代碼來源:fabfile.py

示例15: unlink_current

# 需要導入模塊: from fabric.contrib import console [as 別名]
# 或者: from fabric.contrib.console import confirm [as 別名]
def unlink_current():
    """
    Unlinks the current code directory. Use with caution.
    """
    message = 'Are you sure you want to unlink the current release of {env.deploy_env}?'.format(env=env)

    if not console.confirm(message, default=False):
        utils.abort('Deployment aborted.')

    if files.exists(env.code_current):
        sudo('unlink {}'.format(env.code_current)) 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:13,代碼來源:fabfile.py


注:本文中的fabric.contrib.console.confirm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。