當前位置: 首頁>>代碼示例>>Python>>正文


Python WaterButlerPath.from_metadata方法代碼示例

本文整理匯總了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
開發者ID:CenterForOpenScience,項目名稱:waterbutler,代碼行數:33,代碼來源:copy.py

示例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
開發者ID:ccfair,項目名稱:waterbutler,代碼行數:35,代碼來源:move.py

示例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)
開發者ID:ccfair,項目名稱:waterbutler,代碼行數:10,代碼來源:log_payload.py


注:本文中的waterbutler.core.path.WaterButlerPath.from_metadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。