本文整理汇总了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
))
示例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.')
示例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)
示例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()
示例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()
示例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)
# -------------------------------------------------------------------------------
示例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)
# -------------------------------------------------------------------------------
示例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)
# -------------------------------------------------------------------------------
示例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)
# -------------------------------------------------------------------------------
示例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)
# -------------------------------------------------------------------------------
示例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
)()
# -------------------------------------------------------------------------------
示例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)()
示例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.')
示例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"
)
示例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))