本文整理汇总了Python中console.Console.success方法的典型用法代码示例。如果您正苦于以下问题:Python Console.success方法的具体用法?Python Console.success怎么用?Python Console.success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类console.Console
的用法示例。
在下文中一共展示了Console.success方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from console import Console [as 别名]
# 或者: from console.Console import success [as 别名]
class Deploy:
def __init__(self):
self.config = Conf()
self.console = Console()
def path(self, option):
path = self.config.get(option)
return os.path.abspath(path);
def chown(self, path):
user = self.config.get('deploy_user')
self.console.run(['chown', '-R', user, path])
def linkdir(self, src, dst):
self.console.run(['ln', '-sfn', src, dst])
def version(self, deploy_path):
hash = self.console.run(['git', 'rev-parse', 'HEAD'], cwd=deploy_path);
return hash[0:8]
def hostname(self):
hostname = self.console.run(['hostname', '-f'], output=False);
return hostname
def sync(self, src, dst):
if os.path.exists(src) == False:
os.makedirs(src, 0755)
self.console.run([
'rsync',
'--links',
'--checksum',
'--whole-file',
'--recursive',
src.rstrip('/') + '/',
dst
])
def checkout(self):
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:]:
#.........这里部分代码省略.........