Skip to main content

canonicalwebteam.launchpad

Classes for triggering builds of snaps and Ubuntu images through the Launchpad API.

Usage

Local development

For local development, it's best to test this module with one of our website projects like ubuntu.com. For more information, follow this guide (internal only).

SnapBuilder

from canonicalwebteam.launchpad import SnapBuilder

snap_builder = SnapBuilder(
    username="build.snapcraft.io",
    token=os.getenv("SNAP_BUILDER_TOKEN"),
    secret=os.getenv("SNAP_BUILDER_SECRET"),
)

snap_name = "new-test-snap"
git_repo = "https://github.com/build-staging-snapcraft-io/test1"
snap_builder.create_snap(snap_name, git_repo)

new_snap = snap_builder.get_snap_by_store_name("new-test-snap")

create_snap authorizes store uploads using a root macaroon (typically obtained from the store's package_upload ACL endpoint). If that macaroon carries a third-party (SSO) caveat, Launchpad needs the matching discharge_macaroon as well, otherwise it will accept the authorization but never actually be able to upload builds — leaving every build stuck as "Unscheduled" ("Won't release") with no error surfaced:

snap_builder.create_snap(
    snap_name, git_repo, macaroon, discharge_macaroon=discharge_macaroon
)

Snaps that were created before a discharge macaroon was available can be repaired without recreating them, using complete_snap_authorization:

snap_builder.complete_snap_authorization(
    lp_snap_name, macaroon, discharge_macaroon=discharge_macaroon
)

ImageBuilder

from canonicalwebteam.launchpad import ImageBuilder

image_builder = ImageBuilder(
    username="image.build",
    token=os.getenv("IMAGE_BUILDER_TOKEN"),
    secret=os.getenv("IMAGE_BUILDER_SECRET"),
)

image_builder.build_image(
    board="cm3", system="core16", snaps=["code", "toto"]
)

Test fixtures

Tests check calls against fixtures representing the Launchpad API. These fixtures are generated using vcrpy, based on real calls to the API when the test was first run.

To new tests that rely on new API responses, or if we need to regenerate existing fixtures because the API has changed, the secrets need to be provided to authenticate with the API as follows:

export SNAP_BUILDER_TOKEN={token}
export SNAP_BUILDER_SECRET={secret}
export IMAGE_BUILDER_TOKEN={token}
export IMAGE_BUILDER_SECRET={secret}

rm tests/cassettes/...  # Remove any fixtures you need to regenerate

./setup.py test  # Run tests again to regenerate fixtures

Download files

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

Source Distribution

canonicalwebteam_launchpad-0.10.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

canonicalwebteam_launchpad-0.10.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file canonicalwebteam_launchpad-0.10.0.tar.gz.

File metadata

File hashes

Hashes for canonicalwebteam_launchpad-0.10.0.tar.gz
Algorithm Hash digest
SHA256 7bf7ccee7265aaaedf9c04dea16b3f844b202b0a46ab3458855d1967f609b2cf
MD5 be885dae65b46d28bb73b5163a210509
BLAKE2b-256 6ca2745dad0fbe6444811bf1961be8ff6b41113774b7ecec15cac6c88d80de43

See more details on using hashes here.

File details

Details for the file canonicalwebteam_launchpad-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for canonicalwebteam_launchpad-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b807c3a02ef77940c4eeebebb4e0f75c29277ff09a1a95f111050da9572154db
MD5 6c0ec0fad71f1b07e73e49e806cd371a
BLAKE2b-256 36b380ec7ddc4c702d6154f6259e328b7bea0182eaac1fe9f92fe49eae05cc2a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 files

0.9.0

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.9

2 files

0.7.8

2 files

0.7.7

2 files

0.7.6

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page