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
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
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)
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)
async def copy(src_bundle, dest_bundle, request=None, start_time=None, **kwargs): request = request or {} start_time = start_time or time.time() src_path = src_bundle.pop('path') src_provider = utils.make_provider(**src_bundle.pop('provider'), is_celery_task=True) dest_path = dest_bundle.pop('path') dest_provider = utils.make_provider(**dest_bundle.pop('provider'), is_celery_task=True) 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