Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import datetime
import json
import requests
import kinto_http
def buildid2iso(buildid):
return datetime.datetime.strptime(buildid, "%Y%m%d%H%M%S").isoformat()
def main():
source_client = kinto_http.Client(server_url="",
bucket="systemaddons", collection="versions"
auth=("user", "pass"))
records = source_client.get_records()
dest_client = kinto_http.Client(server_url="http://localhost:8888/v1",
auth=("user", "pass"))
with dest_client.batch() as batch:
for record in records:
buildid = record["release"]["buildId"]
url = record["release"]["url"]
resp = requests.head(url)
size = int(resp.headers.get("Content-Length", 0))
mimetype = resp.headers.get("Content-Type")
addons_by_ids = {}
for addon in record["builtins"]:
addons_by_ids[addon["id"]] = {"id": addon["id"], "builtin": addon["version"]}
for addon in record["updates"]:
addons_by_ids.setdefault(addon["id"], {}).update({"id": addon["id"], "updated": addon["version"]})
systemaddons = list(addons_by_ids.values())
tree = {
"beta": "mozilla-beta",
"aurora": "mozilla-aurora",
"release": "mozilla-release",
"nightly": "mozilla-central"
fixture = {
"build": {
"id": buildid,
"date": buildid2iso(buildid),
"type": "opt"
"source": {
"revision": record["id"], # fake rev!
"tree": tree,
"product": "firefox",
"target": {
"platform": record["release"]["target"],
"locale": record["release"]["lang"],
"version": record["release"]["version"],
"channel": record["release"]["channel"],
"download": {
"url": url,
"mimetype": mimetype,
"size": size,
"systemaddons": systemaddons
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.