Skip to content

Instantly share code, notes, and snippets.

@leplatrem leplatrem/bulk.py
Last active Feb 21, 2018

Embed
What would you like to do?
bulk plugins update + request review
import os
from kinto_http import Client
FIREFOX_GUID = "ec8030f7-c20a-464f-9b0e-13a3a9e97384"
SERVER = os.getenv("SERVER") or "https://settings-writer.prod.mozaws.net/v1"
USERNAME = os.getenv("USERNAME")
PASSWORD = os.getenv("PASSWORD")
client = Client(server_url=SERVER, auth=(USERNAME, PASSWORD),
bucket='staging', collection='plugins')
records = client.get_records()
# 1. Change records in the «staging» bucket.
with client.batch() as batch:
for record in records:
# As of 21 feb 2018, no record with several version ranges.
versionRange = record.get("versionRange")
if versionRange is None or len(versionRange) == 0:
versionRange = [{}]
targetApplications = versionRange[0].get("targetApplication")
if targetApplications is None or len(targetApplications) == 0:
targetApplications = [{}]
for ta in targetApplications:
if "guid" not in ta:
ta[0]["guid"] = FIREFOX_GUID
ta[0]["maxVersion"] = "57.0.*"
elif ta.get("guid") == FIREFOX_GUID:
ta.setdefault("maxVersion", "57.0.*")
versionRange[0]["targetApplication"] = targetApplications
record["versionRange"] = versionRange
batch.update_record(record)
# 2. Request a review.
client.patch_collection(data={"status": "to-review"})
# 3. Approve changes via the UI.
# Or with a call to client.patch_collection(data={"status": "to-sign"})
# as a different user (member of the reviewers group)
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.