本文整理汇总了Python中fabric.colors.red方法的典型用法代码示例。如果您正苦于以下问题:Python colors.red方法的具体用法?Python colors.red怎么用?Python colors.red使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fabric.colors
的用法示例。
在下文中一共展示了colors.red方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [as 别名]
def setup(config_file_path):
global config
global data
global backup_local_file
try:
config = yaml.load(open(config_file_path))
except IOError as e:
print(str(e))
abort(colors.red("No such file. Please add a configuration "
"file similar to sample_config.yaml\n"))
except Exception as e:
print(str(e))
abort(colors.red("Please check the configuration file. "
"It should be a YAML file similar to "
"sample_config.yaml\n"))
else:
if config is None:
config = {}
data = config.get("local") or {}
if data and data.get("project_root"):
backup_local_file = data.get("project_root") + \
'/local_db_backup_%s.sql' % str(datetime.now().date())
示例2: is_manager
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [as 别名]
def is_manager(self, raise_manager_error=True):
is_manager = self.managers.get(fab.env.host)
try:
if is_manager is None:
is_manager = self.managers[fab.env.host] = self._is_manager()
except fabricio.host_errors as error:
is_manager = self.managers[fab.env.host] = False
fabricio.log(
'WARNING: {error}'.format(error=error),
output=sys.stderr,
color=colors.red,
)
finally:
if (
raise_manager_error
and len(self.managers) >= len(fab.env.all_hosts)
and not any(self.managers.values())
):
msg = 'service manager not found or it failed to pull image'
raise ManagerNotFoundError(msg)
return is_manager
示例3: restart_core
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [as 别名]
def restart_core():
print green('Restart the core platform via the restart.sh scripts.')
ret = run("ps -ef|grep newark-core-platform|grep -v grep|cut -c 9-15")
if ret:
with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
run("ps -ef|grep newark-core-platform|grep -v grep|cut -c 9-15|xargs kill -9 2>/dev/null >/dev/null")
else:
print red("No such progress!")
ret_new = run("ps -ef|grep newark-core-platform|grep -v grep|cut -c 9-15")
if ret_new:
print red("Startup already!")
else:
with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
run('cd '+core_platform_path+' && java -jar newark-core-platform-'+core_version+'.jar 2>/dev/null >/dev/null')
print green('Restart the core platform finished!')
# Shutdown the auth platform via the stop.sh scripts function.
示例4: deploy_prepare
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [as 别名]
def deploy_prepare():
print green('Deploy prepared. Run as root.')
# Install jdk 1.8.25.
print red('This program require jdk 1.8.25. Make sure jdk and tomcat work out before all of your operations.')
#Install Maven
print green('Install maven.')
print 'Logs output to the '+log_path+'/deploy_prepare.log'
os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
os.system("echo '' > "+log_path+"/deploy_prepare.log")
os.system("fab -f "+script_name+" deploy_prepare > "+log_path+"/deploy_prepare.log")
print green('Deploy prepared finished.')
# Update the databae setting.
示例5: deploylive
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [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)
# -------------------------------------------------------------------------------
示例6: deploystaging
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [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)
# -------------------------------------------------------------------------------
示例7: restartlive
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [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)
# -------------------------------------------------------------------------------
示例8: restartstaging
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [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)
# -------------------------------------------------------------------------------
示例9: restartchesster
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [as 别名]
def restartchesster():
if confirm(colors.red("Would you like to restart chesster?")):
sudo("/usr/sbin/service chesster restart", shell=False)
# -------------------------------------------------------------------------------
示例10: latest_live_media
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [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
)()
# -------------------------------------------------------------------------------
示例11: latest_live_db
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [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)()
示例12: get_function
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [as 别名]
def get_function():
if not config:
abort(colors.red("Please check the configuration file. "
"It should be a YAML file similar to "
"sample_config.yaml\n"))
if run_on == "local":
return local
else:
if not env.hosts:
print("Please check the hosts(servers) settings for '%s' "
"in the config file." % str(run_on))
return None
return run
示例13: _print_stats
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [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)))
示例14: parse_int_or_exit
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [as 别名]
def parse_int_or_exit(val):
try:
return int(val)
except (ValueError, TypeError):
print(red("Unable to parse '{}' into an integer".format(val)))
exit()
示例15: apply_patch
# 需要导入模块: from fabric import colors [as 别名]
# 或者: from fabric.colors import red [as 别名]
def apply_patch(patchfile=None):
"""
Used to apply a git patch created via `git format-patch`. Usage:
fab <env> apply_patch:patchfile=/path/to/patch
Note: Only use this when absolutely necessary. Normally we should use regular
deploy. This is only used for patching when we do not have access to the Internet.
"""
if not patchfile:
print(red("Must specify patch filepath"))
exit()
execute(release.apply_patch, patchfile)
silent_services_restart(use_current_release=True)