Beispiel #1
0
def retrieve(data_item, cache=None):
    """ 
    """

    backend = BackendComponent(env)

    if cache is None:
        cache = get_cache_context()

    # compute a cache path where the file *would* be cached
    with cache:
        item_id = generate_hash(data_item.location, data_item.format)
        path = cache.relative_path(item_id)

        logger.debug("Retrieving %s (ID: %s)" % (data_item, item_id))

        if item_id in cache:
            logger.debug("Item %s is already in the cache." % item_id)
            return path
        
        if data_item.package is None and data_item.storage:
            return _retrieve_from_storage(
                backend, data_item, data_item.storage, item_id, path, cache
            )

        elif data_item.package:
            return _extract_from_package(
                backend, data_item, data_item.package, item_id, path, cache
            )

        else:
            return data_item.location
Beispiel #2
0
def retrieve(data_item, cache=None):
    """ 
    """

    backend = BackendComponent(env)

    if cache is None:
        cache = get_cache_context()

    # compute a cache path where the file *would* be cached
    with cache:
        item_id = generate_hash(data_item.location, data_item.format)
        path = cache.relative_path(item_id)

        logger.debug("Retrieving %s (ID: %s)" % (data_item, item_id))

        if item_id in cache:
            logger.debug("Item %s is already in the cache." % item_id)
            return path

        if data_item.package is None and data_item.storage:
            return _retrieve_from_storage(backend, data_item, data_item.storage, item_id, path, cache)

        elif data_item.package:
            return _extract_from_package(backend, data_item, data_item.package, item_id, path, cache)

        else:
            return data_item.location
Beispiel #3
0
def retrieve(data_item, cache=None):
    """ Retrieve a :class:`DataItem <eoxserver.backends.models.DataItem>`, i.e:
    make it locally available. This takes into account any download from a
    :class:`Storage <eoxserver.backends.models.Storage>` and any unpacking from
    a :class:`Package <eoxserver.backends.models.Package>` the ``DataItem``
    might be contained in.

    :param data_item: the :class:`DataItem <eoxserver.backends.models.DataItem>`
                      to connect retrieve
    :param cache: an instance of :class:`CacheContext
                  <eoxserver.backends.cache.CacheContext>` or ``None``
                  if the caching shall be handled internally
    """

    backend = BackendComponent(env)

    if cache is None:
        cache = get_cache_context()

    # compute a cache path where the file *would* be cached
    with cache:
        item_id = generate_hash(data_item.location, data_item.format)
        path = cache.relative_path(item_id)

        logger.debug("Retrieving %s (ID: %s)" % (data_item, item_id))

        if item_id in cache:
            logger.debug("Item %s is already in the cache." % item_id)
            return path

        if data_item.package is None and data_item.storage:
            return _retrieve_from_storage(
                backend, data_item, data_item.storage, item_id, path, cache
            )

        elif data_item.package:
            return _extract_from_package(
                backend, data_item, data_item.package, item_id, path, cache
            )

        else:
            return data_item.location
Beispiel #4
0
def retrieve(data_item, cache=None):
    """ Retrieve a :class:`DataItem <eoxserver.backends.models.DataItem>`, i.e:
    make it locally available. This takes into account any download from a
    :class:`Storage <eoxserver.backends.models.Storage>` and any unpacking from
    a :class:`Package <eoxserver.backends.models.Package>` the ``DataItem``
    might be contained in.

    :param data_item: the :class:`DataItem <eoxserver.backends.models.DataItem>`
                      to connect retrieve
    :param cache: an instance of :class:`CacheContext
                  <eoxserver.backends.cache.CacheContext>` or ``None``
                  if the caching shall be handled internally
    """

    backend = BackendComponent(env)

    if cache is None:
        cache = get_cache_context()

    # compute a cache path where the file *would* be cached
    with cache:
        item_id = generate_hash(data_item.location, data_item.format)
        path = cache.relative_path(item_id)

        logger.debug("Retrieving %s (ID: %s)" % (data_item, item_id))

        if item_id in cache:
            logger.debug("Item %s is already in the cache." % item_id)
            return path

        if data_item.package is None and data_item.storage:
            return _retrieve_from_storage(backend, data_item,
                                          data_item.storage, item_id, path,
                                          cache)

        elif data_item.package:
            return _extract_from_package(backend, data_item, data_item.package,
                                         item_id, path, cache)

        else:
            return data_item.location