本文整理汇总了Python中fs.osfs.OSFS.copydir方法的典型用法代码示例。如果您正苦于以下问题:Python OSFS.copydir方法的具体用法?Python OSFS.copydir怎么用?Python OSFS.copydir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs.osfs.OSFS
的用法示例。
在下文中一共展示了OSFS.copydir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deploy_register
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import copydir [as 别名]
def deploy_register():
"""Put the staging version to production hosted at
register.geostandaarden.nl
"""
## TODO: feed this function absolute paths
print "Deploying production..."
logging.info("Deploying production...")
production = OSFS(production_path)
# NOTE: only build paths within script_dir are currently supported
call ('cp -r %s %s' % (ospath.join(build_path, register_path), ospath.join(production_path, register_path + '-new')), shell=True)
if production.exists(register_path):
backup_dir = time.strftime('%Y-%m-%d-%H-%M-%S')
production.copydir(register_path, '%s/%s' % (backups_path, backup_dir), overwrite=True)
try:
production.movedir(register_path, register_path + '-old', overwrite=True)
except ResourceNotFoundError:
pass
production.movedir(register_path + '-new', register_path, overwrite=True)
try:
production.removedir(register_path + '-old', force=True)
except ResourceNotFoundError:
pass
call('chmod -R a+rx %s/%s' % (production_path, register_path), shell=True)
logging.info("Production built successfully!")
示例2: create_production
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import copydir [as 别名]
def create_production(build_dir, backups, script_dir):
"""Put the staging version to production hosted at
register.geostandaarden.nl
"""
print "Building production..."
logging.info("Building production...")
deploy = OSFS('..')
if deploy.exists(backups) == False:
deploy.makedir(backups)
deploy.copydir('%s/%s' % (script_dir, build_dir), 'register-new', overwrite=True)
if deploy.exists('register') == True:
# server refuses to recursively remove register/staging
# hence we excplicitly remove symbolic link to staging
try:
deploy.remove('register/staging/staging')
except ResourceNotFoundError:
print "Warning, register/staging/staging not found..."
try:
deploy.removedir('register/staging')
except ResourceNotFoundError:
print "Warning, register/staging not found..."
backup_dir = time.strftime('%Y-%m-%d-%H-%M-%S')
# if deploy.exists('backups/%s' % backup_dir):
# deploy.removedir('backups/%s' % backup_dir, force=True)
deploy.copydir('register', 'backups/%s' % backup_dir, overwrite=True)
try:
deploy.movedir('register', 'register-old', overwrite=True)
except ResourceNotFoundError:
pass
deploy.movedir('register-new', 'register', overwrite=True)
# create symbolic link to standalone staging directory
# fails if production is built first...
deploy.makedir('register/staging')
call('cd ../register/staging; ln -s ../../staging', shell=True)
call('cd ../register; ln -s ../%s/log.txt' % script_dir , shell=True)
try:
deploy.removedir('register-old', force=True)
except ResourceNotFoundError:
pass
call('chmod -R a+rx ../register', shell=True)
print "Done building production..."
logging.info("Production built successfully!")
示例3: create_production
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import copydir [as 别名]
def create_production(destination, backups, script_entry_path, production_path):
"""Put the staging version to production hosted at
register.geostandaarden.nl
"""
## TODO: feed this function absolute paths
print "Building production..."
logging.info("Building production...")
production = OSFS(production_path)
# if production.exists(backups) == False:
# production.makedir(backups)
# copy newly baked register/staging to production directory
# NOTE: only build paths within script_dir are currently supported
call ('cp -r %s %s' % (ospath.join(build_path, destination), ospath.join(production_path, destination + '-new')), shell=True)
# production.copydir('%s/%s/%s' % (script_dir, build_path, destination), destination + '-new', overwrite=True)
if production.exists(destination) == True:
# server refuses to recursively remove register/staging
# hence we excplicitly remove symbolic link to staging
try:
production.remove('%s/staging/staging' % destination)
except ResourceNotFoundError:
print "Warning, %s/staging/staging not found..." % destination
try:
production.removedir('%s/staging' % destination)
except ResourceNotFoundError:
print "Warning, %s/staging not found..." % destination
backup_dir = time.strftime('%Y-%m-%d-%H-%M-%S')
# if production.exists('backups/%s' % backup_dir):
# production.removedir('backups/%s' % backup_dir, force=True)
production.copydir(destination, '%s/%s' % (backups, backup_dir), overwrite=True)
try:
production.movedir(destination, destination + '-old', overwrite=True)
except ResourceNotFoundError:
pass
production.movedir(destination + '-new', destination, overwrite=True)
# create symbolic link to standalone staging directory
# fails if production is built first...
production.makedir('%s/staging' % destination)
call('cd %s; ln -s %s' % (ospath.join(production_path, destination, 'staging'), ospath.join(production_path, 'staging')), shell=True)
call('cd %s; ln -s %s' % (ospath.join(production_path, destination), ospath.join(script_entry_path, 'log.txt')), shell=True)
try:
production.removedir(destination + '-old', force=True)
except ResourceNotFoundError:
pass
call('chmod -R a+rx %s/%s' % (production_path, destination), shell=True)
print "Done building production..."
logging.info("Production built successfully!")