Skip to main content

Pacifica Python Downloader

Project description

Pacifica Python Downloader

Build Status Build Status Test Coverage Maintainability

Pacifica Python Library for Downloading Data

This repository provides a library so python applications can download data from Pacifica.

Downloader API

The entrypoint for this library is the Downloader class in the downloader module. Instances of this class are created with a download directory and a Pacifica Cartd endpoint url.

Downloader Class

The constructor takes two arguments location and cart_api_url. The location is a download directory to be created by a download method. The cart_api_url is the endpoint for creating carts.

The other methods in the Downloader class are the supported download methods. Each method takes appropriate input for that method and the method will download the data to the location defined in the constructor.

CloudEvents is a standard for how to send messages between services in cloud environments. The cloudevent() method (here) consumes the event emitted by the Pacifica Notifications service and downloads the data.

Internal Classes and Methods

The internal classes help organize the work around the cart API.

Cart API

The CartAPI class has two methods used for setting up a cart and waiting for completion.

The setup_cart() method takes a callable argument that returns an iterator. The iterator returns a list that is directly sent to the Cartd API. The setup_cart() method returns the full url to the cart created.

The wait_for_cart() method takes a cart url returned from the setup_cart() method and polls the endpoint until the cart is ready to download.

CloudEvent

The CloudEvent class (here) contains the cloudevent() method. It requires the cloud event as an argument. The cloudevent() generates a method that yields the cart file objects from the cloud event.

Examples

CloudEvents Example

This is a basic stub code to download data from a cloud event. This assumes the cloudevent is saved to a file for processing. There are a number of ways to get the cloud event this is just a minimum representation of whats required.

from json import loads
from tempfile import mkdtemp
from pacifica.downloader import Downloader

cloud_event = loads(open('cloudevent.json').read())
down_path = mkdtemp()
down = Downloader(down_path, 'http://metadata.example.com')
down.cloudevent(cloud_event)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pacifica-downloader-0.3.0.tar.gz (14.5 kB view hashes)

Uploaded Source

Built Distributions

pacifica_downloader-0.3.0-py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 3

pacifica_downloader-0.3.0-py2-none-any.whl (8.9 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page