pypicloud.storage.base module¶
Base class for storage backends
- class pypicloud.storage.base.IStorage(request: Request, **kwargs)[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: Package) None [source]¶
Delete a package file
- Parameters
- package
Package
The package metadata
- package
- download_response(package: Package)[source]¶
Return a HTTP Response that will download this package
This is called from the download endpoint
- get_url(package: 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
- linkstr
Link to the location of this package file
- list(factory: ~typing.Type[~pypicloud.models.Package] = <class 'pypicloud.models.Package'>) List[Package] [source]¶
Return a list or generator of all packages
- open(package: 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
- package
Examples
with storage.open(package) as pkg_data: with open('outfile.tar.gz', 'w') as ofile: ofile.write(pkg_data.read())