本文整理汇总了Python中fs.osfs.OSFS.removedir方法的典型用法代码示例。如果您正苦于以下问题:Python OSFS.removedir方法的具体用法?Python OSFS.removedir怎么用?Python OSFS.removedir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs.osfs.OSFS
的用法示例。
在下文中一共展示了OSFS.removedir方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deploy_register
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import removedir [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 removedir [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: remove_dir
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import removedir [as 别名]
def remove_dir(self, path):
"""Remove a folder at a given path."""
try:
file_to_delete = os.path.basename(path)
to_delete_from = OSFS(os.path.dirname(path))
to_delete_from.removedir(file_to_delete,
recursive=True,
force=True)
except ResourceNotFoundError:
raise ArchiverError("Folder %s not found" % path)
示例4: _zip
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import removedir [as 别名]
def _zip(self, destination=None):
"""Compresse a bagit file."""
# Removes the final forwardslash if there is one
destination = destination or cfg["ARCHIVER_TMPDIR"]
if destination.endswith(os.path.sep):
destination = destination[:-len(os.path.sep)]
filename = os.path.join(destination, "{0}.zip".format(self.name))
# Create and FS object
with OSFS(self.folder) as to_zip_fs:
with ZipFS(filename, mode='w') as zip_fs:
copydir(to_zip_fs, zip_fs, overwrite=True)
file_to_delete = os.path.basename(self.folder)
to_delete_from = OSFS(os.path.dirname(self.folder))
to_delete_from.removedir(file_to_delete, recursive=True,
force=True)
return filename
示例5: cleanup
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import removedir [as 别名]
def cleanup(source, destination_temp, standard):
"""Remove the source and temporary destination folders."""
try:
source_fs = OSFS('%s/%s' % (source, standard))
except ResourceNotFoundError:
return None
destination_fs = OSFS(destination_temp)
artifacts = source_fs.listdir(dirs_only=True)
if '.git' in artifacts: artifacts.remove('.git')
for artifact in artifacts:
path = '%s/%s' % (artifact, standard)
if destination_fs.exists(path):
destination_fs.removedir(path, force=True)
if destination_fs.exists(standard): destination_fs.removedir(standard, force=True)
示例6: create_staging
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import removedir [as 别名]
def create_staging(staging_path, production_path, build_path):
"""Create a staging version of the register hosted at
register.geostandaarden.nl/staging
"""
logging.info("Building staging...")
production = OSFS(production_path)
print "Removing current staging..."
if production.exists(staging_path):
production.removedir(staging_path, force=True)
print 'Moving new register to staging...'
# OSFS cannot copy to arbitrary locations
call('cp -r %s %s' % (ospath.join(build_path, staging_path), production_path), shell=True)
call('chmod -R a+rx %s' % (ospath.join(production_path, staging_path)), shell=True)
logging.info("Staging built successfully!")
示例7: create_production
# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import removedir [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!")