本文整理汇总了Python中unipath.Path.endswith方法的典型用法代码示例。如果您正苦于以下问题:Python Path.endswith方法的具体用法?Python Path.endswith怎么用?Python Path.endswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unipath.Path
的用法示例。
在下文中一共展示了Path.endswith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restore
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import endswith [as 别名]
def restore(dbname, local_file):
'''
Restore a MySQL dump into dbname.
Usage: fab db.mysql.backup
'''
local_file = Path(local_file).absolute()
remote_file = Path(put(local_file, env.PROJECT.tmp, use_sudo=True)[0])
if remote_file.endswith('.bz2'):
sudo('bunzip2 ' + remote_file)
remote_file = remote_file.parent.child(remote_file.stem)
sudo('mysql --defaults-extra-file=/root/.my.cnf -e "DROP DATABASE %(dbname)s; CREATE DATABASE %(dbname)s;"' % locals())
sudo('mysql --defaults-extra-file=/root/.my.cnf %(dbname)s < %(remote_file)s' % locals())
# cleanup
sudo('rm ' + remote_file)
示例2: restore
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import endswith [as 别名]
def restore(local_file, dbname=None, dbuser=None):
'''
Restore a MySQL dump into dbname.
Usage: fab db.mysql.backup
'''
require('PROJECT')
dbname = dbname or env.PROJECT.appname
dbuser = dbname or env.PROJECT.appname
local_file = Path(local_file).absolute()
remote_file = Path(put(local_file, env.PROJECT.tmp)[0])
if remote_file.endswith('.bz2'):
run('bunzip2 ' + remote_file)
remote_file = remote_file.parent.child(remote_file.stem)
with settings(warn_only=True):
run('pg_restore --verbose --clean -U %(dbuser)s -d %(dbname)s %(remote_file)s' % locals())
# cleanup
run('rm ' + remote_file)