本文整理匯總了Python中waterbutler.core.path.WaterButlerPath.from_metadata方法的典型用法代碼示例。如果您正苦於以下問題:Python WaterButlerPath.from_metadata方法的具體用法?Python WaterButlerPath.from_metadata怎麽用?Python WaterButlerPath.from_metadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類waterbutler.core.path.WaterButlerPath
的用法示例。
在下文中一共展示了WaterButlerPath.from_metadata方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: copy
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import from_metadata [as 別名]
async def copy(src_bundle, dest_bundle, request={}, start_time=None, **kwargs):
start_time = start_time or time.time()
src_path, src_provider = src_bundle.pop('path'), utils.make_provider(**src_bundle.pop('provider'))
dest_path, dest_provider = dest_bundle.pop('path'), utils.make_provider(**dest_bundle.pop('provider'))
logger.info('Starting copying {!r}, {!r} to {!r}, {!r}'
.format(src_path, src_provider, dest_path, dest_provider))
metadata, errors = None, []
try:
metadata, created = await src_provider.copy(dest_provider, src_path, dest_path, **kwargs)
except Exception as e:
logger.error('Copy failed with error {!r}'.format(e))
errors = [e.__repr__()]
raise # Ensure sentry sees this
else:
logger.info('Copy succeeded')
dest_path = WaterButlerPath.from_metadata(metadata)
finally:
source = LogPayload(src_bundle['nid'], src_provider, path=src_path)
destination = LogPayload(
dest_bundle['nid'], dest_provider, path=dest_path, metadata=metadata
)
await remote_logging.wait_for_log_futures(
'copy', source=source, destination=destination, start_time=start_time,
errors=errors, request=request, api_version='celery',
)
return metadata, created
示例2: move
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import from_metadata [as 別名]
async def move(src_bundle, dest_bundle, start_time=None, **kwargs):
start_time = start_time or time.time()
src_path, src_provider = src_bundle.pop('path'), utils.make_provider(**src_bundle.pop('provider'))
dest_path, dest_provider = dest_bundle.pop('path'), utils.make_provider(**dest_bundle.pop('provider'))
logger.info('Starting moving {!r}, {!r} to {!r}, {!r}'.format(src_path, src_provider, dest_path, dest_provider))
metadata, errors = None, []
try:
metadata, created = await src_provider.move(dest_provider, src_path, dest_path, **kwargs)
except Exception as e:
logger.error('Move failed with error {!r}'.format(e))
errors = [e.__repr__()]
raise # Ensure sentry sees this
else:
logger.info('Move succeeded')
dest_path = WaterButlerPath.from_metadata(metadata)
finally:
source = LogPayload(src_bundle['nid'], src_provider, path=src_path)
destination = LogPayload(
dest_bundle['nid'], dest_provider, path=dest_path, metadata=metadata
)
await utils.log_to_callback(
'move',
source=source,
destination=destination,
start_time=start_time,
errors=errors
)
return metadata, created
示例3: __init__
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import from_metadata [as 別名]
def __init__(self, resource, provider, metadata=None, path=None):
if path is None and metadata is None:
raise Exception("Log payload needs either a path or metadata.")
self.resource = resource
self.provider = provider
self.metadata = metadata
self.path = path or WaterButlerPath.from_metadata(metadata)