eoxserver.backends package

Submodules

eoxserver.backends.access module

exception eoxserver.backends.access.AccessError

Bases: Exception

eoxserver.backends.access.gdal_open(data_item, shared=True)

Opens a eoxserver.backends.models.DataItem as a eoxserver.contrib.gdal.Dataset. Uses get_vsi_path() internally to get the path.

Parameters:data_item (eoxserver.backends.models.DataItem) – the data item to open as a dataset.
Return type:eoxserver.contrib.gdal.Dataset
eoxserver.backends.access.get_vsi_env(storage)
eoxserver.backends.access.get_vsi_path(data_item)

Get the VSI path to the given eoxserver.backends.models.DataItem

Parameters:data_item (eoxserver.backends.models.DataItem) – the data item to get the path to
Returns:the VSI file path which is can be used with GDAL-related APIs
Return type:str
eoxserver.backends.access.get_vsi_storage_path(storage, location=None)
eoxserver.backends.access.open(data_item, cache=None)

Returns a file object pointing to the given location. This function works like the builtin function open() but on a DataItem and performs a retrieve() first.

Parameters:
  • data_item – the DataItem to open
  • cache – an instance of CacheContext or None if the caching shall be handled internally
eoxserver.backends.access.retrieve(data_item, cache=None)

Retrieves the eoxserver.backends.models.DataItem and makes the file locally available if necessary. When the data item is not associated with a storage, then the data items location will be returned. Otherwise, the storage handlers retrieve method will be called to make the data item locally available.

Parameters:
Returns:

the path to the localized file

Return type:

str

eoxserver.backends.access.vsi_list_storage(storage, location=None, pattern=None)
eoxserver.backends.access.vsi_open(data_item)

Opens a eoxserver.backends.models.DataItem as a eoxserver.contrib.vsi.VSIFile. Uses get_vsi_path() internally to get the path.

Parameters:data_item (eoxserver.backends.models.DataItem) – the data item to open as a VSI file
Return type:eoxserver.contrib.vsi.VSIFile

eoxserver.backends.cache module

class eoxserver.backends.cache.CacheContext(retention_time=None, cache_directory=None, managed=False)

Bases: object

Context manager to manage cached files.

add_mapping(path, item)

Add an external file to this context. Those files will be treated as if they are “within” the caches directory, but will not be clead up afterwards.

add_path(cache_path)

Add a path to this cache context. Also creates necessary sub-directories.

cache_directory

Returns the configured cache directory.

cleanup()

Perform cache cleanup.

contains(cache_path)

Check whether or not the path is contained in this cache.

relative_path(cache_path)

Returns a path relative to the cache directory.

exception eoxserver.backends.cache.CacheException

Bases: Exception

eoxserver.backends.cache.get_cache_context()

Get the thread local cache context for this session. Raises an exception if the session was not initialized.

eoxserver.backends.cache.set_cache_context(cache_context)

Sets the cache context for this session. Raises an exception if there was already a cache context associated.

eoxserver.backends.cache.setup_cache_session(config=None)

Initialize the cache context for this session. If a cache context was already present, an exception is raised.

eoxserver.backends.cache.shutdown_cache_session()

Shutdown the cache context for this session and trigger any pending cleanup actions required.

eoxserver.backends.component module

class eoxserver.backends.component.BackendComponent(*args)

Bases: eoxserver.core.component.Component

This Component provides extension points and helpers to easily retrive Package and Storage components by their type names.

connected_storages

List of components that implement eoxserver.backends.interfaces.ConnectedStorageInterface

file_storages

List of components that implement eoxserver.backends.interfaces.FileStorageInterface

get_connected_storage_component(storage_type)

Retrieve a component implementing the eoxserver.backends.interfaces.ConnectedStorageInterface with the desired storage_type.

Parameters:storage_type – the desired storage type
Returns:the desired storage component or None
get_file_storage_component(storage_type)

Retrieve a component implementing the eoxserver.backends.interfaces.FileStorageInterface with the desired storage_type.

Parameters:storage_type – the desired storage type
Returns:the desired storage component or None
get_package_component(format)

Retrieve a component implementing the eoxserver.backends.interfaces.PackageInterface with the desired format.

Parameters:format – the desired package format
Returns:the desired package component or None
get_storage_component(storage_type)

Retrieve a component implementing the eoxserver.backends.interfaces.FileStorageInterface or eoxserver.backends.interfaces.ConnectedStorageInterface with the desired storage_type.

Parameters:storage_type – the desired storage type
Returns:the desired storage component or None
packages

List of components that implement eoxserver.backends.interfaces.PackageInterface

storages

Helper to retrieve components for all storage interfaces.

eoxserver.backends.config module

class eoxserver.backends.config.CacheConfigReader(config)

Bases: eoxserver.core.decoders.config.Reader

directory
retention_time
section = 'backends'

eoxserver.backends.interfaces module

class eoxserver.backends.interfaces.AbstractStorageInterface

Bases: object

name

Name of the storage implementation.

validate(url)

Validates the given storage locator and raises a django.core.exceptions.ValidationError if errors occurred.

class eoxserver.backends.interfaces.ConnectedStorageInterface

Bases: eoxserver.backends.interfaces.AbstractStorageInterface

Interface for storages that do not store “files” but provide access to data in a different fashion.

connect(url, location)

Return a connection string for a remote dataset residing on a storage specified by the given url and location.

Parameters:
  • url – the URL denoting the storage itself
  • location – the location of the file to retrieve on the storage
Returns:

a connection string to open the stream to actually retrieve data

class eoxserver.backends.interfaces.FileStorageInterface

Bases: eoxserver.backends.interfaces.AbstractStorageInterface

Interface for storages that provide access to files and allow the retrieval of those.

list_files(url, location)

Return a list of retrievable files available on the storage located at the specified URL and given location.

Parameters:
  • url – the URL denoting the storage itself
  • location – a template to find items on the storage
Returns:

an iterable of the storage contents under the specified location

retrieve(url, location, path)

Retrieve a remote file from the storage specified by the given url and location and store it to the given path. Storages that don’t need to actually retrieve and store files, just need to return a path to a local file instead of storing it under path.

Parameters:
  • url – the URL denoting the storage itself
  • location – the location of the file to retrieve on the storage
  • path – a local path where the file should be saved under; this is used as a hint
Returns:

the actual path where the file was stored; in some cases this can be different than the passed path

class eoxserver.backends.interfaces.PackageInterface

Bases: object

extract(package_filename, location, path)

Extract a file specified by the location from the package to the given path specification.

Parameters:
  • package_filename – the local filename of the package
  • location – a location within the package to be extracted
  • path – a local path where the file should be saved under; this is used as a hint
Returns:

the actual path where the file was stored; in some cases this can be different than the passed path

list_contents(package_filename, location_regex=None)

Return a list of item locations under the specified location in the given package.

Parameters:
  • package_filename – the local filename of the package
  • location_regex – a template to find items within the package
Returns:

an iterable of the package contents under the specified location

name

Name of the package implementation.

eoxserver.backends.middleware module

class eoxserver.backends.middleware.BackendsCacheMiddleware

Bases: object

A Django Request Middleware to manage cache setup and teardown when a request is beeing processed.

process_exception(request, exception)
process_request(request)
process_response(request, response)
process_template_response(request, response)

eoxserver.backends.models module

eoxserver.backends.testbase module

eoxserver.backends.testbase.withFTPServer(port=2121, directory=None)

Module contents