Skip to content

Instantly share code, notes, and snippets.

@leplatrem
Last active February 21, 2018 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save leplatrem/391d20cdc590feba5b49488351f853c3 to your computer and use it in GitHub Desktop.
Save leplatrem/391d20cdc590feba5b49488351f853c3 to your computer and use it in GitHub Desktop.
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