pypicloud.storage.base module¶
Base class for storage backends
-
class
pypicloud.storage.base.
IStorage
(request: pyramid.request.Request)[source]¶ Bases:
object
Base class for a backend that stores package files
-
check_health
() → Tuple[bool, str][source]¶ Check the health of the storage backend
Returns: - (healthy, status) : (bool, str)
Tuple that describes the health status and provides an optional status message
-
delete
(package: pypicloud.models.Package) → None[source]¶ Delete a package file
Parameters: - package :
Package
The package metadata
- package :
-
download_response
(package: pypicloud.models.Package)[source]¶ Return a HTTP Response that will download this package
This is called from the download endpoint
-
get_url
(package: pypicloud.models.Package) → str[source]¶ Create or return an HTTP url for a package file
By default this will return a link to the download endpoint
/api/package/<package>/<filename>
Returns: - link : str
Link to the location of this package file
-
list
(factory: Type[pypicloud.models.Package] = <class 'pypicloud.models.Package'>) → List[pypicloud.models.Package][source]¶ Return a list or generator of all packages
-
open
(package: pypicloud.models.Package)[source]¶ Get a buffer object that can read the package data
This should be a context manager. It is used in migration scripts, not directly by the web application.
Parameters: - package :
Package
Examples
with storage.open(package) as pkg_data: with open('outfile.tar.gz', 'w') as ofile: ofile.write(pkg_data.read())
- package :
-