owmeta_core.bundle.loaders.http module¶
- exception owmeta_core.bundle.loaders.http.IndexLoadFailed(response)[source]¶
Bases:
Exception
Thrown when the HTTP bundle loader cannot get its index
- class owmeta_core.bundle.loaders.http.HTTPBundleLoader(index_url, cachedir=None, hash_preference=('sha224',), **kwargs)[source]¶
Bases:
Loader
Loads bundles from HTTP(S) resources listed in an index file
- Parameters
- index_url
str
orowmeta_core.bundle.URLConfig
URL for the index file pointing to the bundle archives
- cachedir
str
,optional
Directory where the index and any downloaded bundle archive should be cached. If provided, the index and bundle archive is cached in the given directory. If not provided, the index will be cached in memory and the bundle will not be cached.
- hash_preference
tuple
of
str
Preference ordering of hashes to use for checking integrity of files. If none match in the preference ordering, then the first one
- **kwargs
Passed on to
Loader
- index_url
- can_load(bundle_id, bundle_version=None)[source]¶
Check the index for an entry for the bundle.
If a version is given and the index has an entry for the bundle at that version and that entry gives a URL for the bundle, then we return
True
.If no version is given and the index has an entry for the bundle at any version and that entry gives a URL for the bundle, then we return
True
.Otherwise, we return
False
- class owmeta_core.bundle.loaders.http.HTTPBundleUploader(upload_url, ssl_context=None, max_retries=1)[source]¶
Bases:
Uploader
Uploads bundles by sending bundle archives in HTTP POST requests
- Parameters
- upload_url
str
orURLConfig
URL string or accessor config
- ssl_context
ssl.SSLContext
,optional
SSL/TLS context to use for the connection. Overrides any context provided in
upload_url
- max_retries
int
,optional
Maximum number of times to retry the upload after a failure.
- upload_url
- upload(bundle_path)[source]¶
Attempt to upload the bundle. Retries will be attempted when
BrokenPipeError
is thrown by the http client
- class owmeta_core.bundle.loaders.http.HTTPSURLConfig(*args, ssl_context_provider=None, ssl_context=None, **kwargs)[source]¶
Bases:
HTTPURLConfig
HTTPS URL configuration
- Parameters
- *args
Passed on to HTTPURLConfig
- ssl_context_provider
str
Path to a callable that provides a
ssl.SSLContext
. Seehttps_remote
- ssl_context
ssl.SSLContext
The SSL/TLS context to use for uploading with this accessor
- **kwargs
Passed on to HTTPURLConfig
- class owmeta_core.bundle.loaders.http.HTTPURLConfig(*args, session_file_name=None, session_provider=None, cache_dir=None, mem_cache=False, **kwargs)[source]¶
Bases:
URLConfig
HTTP URL configuration
- Parameters
- *args
Passed on to URLConfig
- session_file_name
str
,optional
Session file name
- session_provider
str
,optional
Provider path for a callable that returns a session
- cache_dir
str
,optional
HTTP cache directory. Supersedes
mem_cache
- mem_cachebool,
optional
Whether to use an in-memory cache. Superseded by
cache_dir
- **kwargs
Passed on to URLConfig
- init_session()[source]¶
Initialize the HTTP session. Typically you won’t call this, but will just access
session
- property session¶
-
This will be loaded from
session_file_name
if a value is set for that. Otherwise, the session will either be obtained from thesession_provider
or a default session will be created; in either case, any response caching configuration will be applied.
- owmeta_core.bundle.loaders.http.http_remote(self, *, cache=None, session_provider=None, session_file_name=None)[source]¶
Provide additional parameters for HTTP remote accessors
- Parameters
- cache
str
Either the string “mem” or a file path to a cache directory
- session_provider
str
Path to a callable that provides a
requests.Session
. The format is similar to that for setuptools entry points:path.to.module:path.to.provider.callable
. Notably, there’s no name and “extras” are not supported. optional.- session_file_name
str
Path to a file where the HTTP session can be stored
- cache
- owmeta_core.bundle.loaders.http.https_remote(self, *, ssl_context_provider=None, cache=None, session_provider=None, session_file_name=None)[source]¶
Provide additional parameters for HTTPS remote accessors
- Parameters
- ssl_context_provider
str
Path to a callable that provides a
ssl.SSLContext
used for bundle uploads. The format is similar to that for setuptools entry points:path.to.module:path.to.provider.callable
. Notably, there’s no name and “extras” are not supported. optional.- cache
str
Either the string “mem” or a file path to a cache directory
- session_provider
str
Path to a callable that provides a
requests.Session
. The format is similar to that for setuptools entry points:path.to.module:path.to.provider.callable
. Notably, there’s no name and “extras” are not supported. optional.- session_file_name
str
Path to a file where the HTTP session can be stored
- ssl_context_provider