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


Python Console.error方法代码示例

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


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

示例1: __init__

# 需要导入模块: from console import Console [as 别名]
# 或者: from console.Console import error [as 别名]

#.........这里部分代码省略.........
		deploy_path = self.path('release_path') + '/' + time.strftime('%Y%m%d%H%M%S')

		if os.path.exists(deploy_path) == False:
			os.makedirs(deploy_path, 0755)

		gitclone = ' '.join([
			'git',
			'clone',
			'--quiet',
			'--recursive',
			'--depth', '1',
			'--branch', self.config.get('repo_branch'),
			self.config.get('repo_url'),
			deploy_path
		])

		sshadd = ' '.join([
			'ssh-add',
			self.config.get('deploy_key')
		])

		self.console.success('Fetching files')
		self.console.execute('ssh-agent sh -c \'' + sshadd + '; ' + gitclone + '\'')

		return deploy_path

	def composer(self, deploy_path):
		if os.path.exists(deploy_path + '/composer.json') == False:
			return None

		self.console.success('Installing composer dependencies')
		self.console.run([
			'composer',
			'--quiet',
			'--no-interaction',
			'install',
			'--prefer-dist',
			'--no-dev',
			'--optimize-autoloader'
		], cwd=deploy_path);

	def scripts(self, scripts_to_run, deploy_path):
		if self.config.has(scripts_to_run) == False:
			return

		scripts = self.config.get(scripts_to_run)

		for line in scripts:
			command = line.replace('$deploy_path', deploy_path)
			command = command.replace('$repo_branch', self.config.get('repo_branch'))
			command = command.replace('$repo_url', self.config.get('repo_url'))
			command = command.replace('$hostname', self.hostname())
			self.console.run(shlex.split(command), cwd=deploy_path)

	def clean(self):
		release_path = self.path('release_path')
		deployments = self.console.run(['ls', '-1tA', release_path])
		deploys_to_keep = int(self.config.get('deploys_to_keep'))

		for folder in deployments.splitlines()[deploys_to_keep:]:
			self.console.run(['rm', '-rf', folder], cwd=release_path);

	def rollback(self, version):
		deploy_path = self.path('release_path') + '/' + version

		if os.path.exists(deploy_path) == False:
			self.console.error('Version does not exist')
			return None

		self.console.success('Rolling back')
		self.linkdir(deploy_path, self.config.get('symlink'))

	def deploy(self):
		# checkout files
		deploy_path = self.checkout()

		# fetch resources
		self.composer(deploy_path)

		# static resources
		if self.config.has('static_path'):
			self.console.success('Copying static resources')
			self.sync(self.path('static_path'), deploy_path)

		if self.config.has('pre_scripts'):
			self.console.success('Running pre-scripts')
			self.scripts('pre_scripts', deploy_path)

		self.console.success('Updating file owner')
		self.chown(deploy_path)

		self.console.success('Updating symlink')
		self.linkdir(deploy_path, self.config.get('symlink'))

		if self.config.has('post_scripts'):
			self.console.success('Running post-scripts')
			self.scripts('post_scripts', deploy_path)

		self.console.success('Cleaning up old releases')
		self.clean()
开发者ID:,项目名称:,代码行数:104,代码来源:

示例2: len

# 需要导入模块: from console import Console [as 别名]
# 或者: from console.Console import error [as 别名]
#!/usr/bin/env python

import os
import sys

from deploy import Deploy
from console import Console

if __name__ == "__main__":
	if len(sys.argv) < 2:
		print 'Missing config file location'
		sys.exit(0)

	config_path = os.path.abspath(sys.argv[1])

	d = Deploy()
	d.config.read(config_path)

	try:
		if len(sys.argv) == 3:
			d.rollback(sys.argv[2])
		else:
			d.deploy()
	except RuntimeError, e:
		c = Console()
		c.error(str(e))
开发者ID:,项目名称:,代码行数:28,代码来源:


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