def copy_tree(self, origin, destination, ignore=None):
if os.path.exists(destination):
raise shutil.Error(
'''Destination already exists: "{}"'''.format(destination))
self.logger.debug('Copying "%s" to "%s"', origin, destination)
try:
shutil.copytree(origin, destination,
ignore=shutil.ignore_patterns(*ignore or []))
except (shutil.Error, OSError) as error:
try:
shutil.rmtree(destination, ignore_errors=True)
except (shutil.Error, OSError) as strerror:
self.logger.error('Error occurred when cleaning after error: "%s"', strerror)
raise error
评论列表
文章目录