Skip to content
11 changes: 4 additions & 7 deletions scripts/pinned_browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def calculate_hash(url):
print(f"Calculate hash for {url}", file=sys.stderr)
h = hashlib.sha256()
r = http.request("GET", url, preload_content=False)
if r.status != 200:
raise ValueError(f"Download unavailable (HTTP {r.status}): {url}")
for b in iter(lambda: r.read(4096), b""):
h.update(b)
return h.hexdigest()
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Expand All @@ -28,14 +30,9 @@ def calculate_hash(url):
def get_chrome_info_for_channel(channel):
r = http.request(
"GET",
f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux",
"https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json",
)
all_versions = json.loads(r.data)
# use the same milestone for all chrome releases, so pick the lowest
milestones = [version["milestone"] for version in all_versions if version["milestone"]]
if not milestones:
raise ValueError(f"No Chrome versions with milestones found for channel '{channel}'")
milestone = min(milestones)
milestone = json.loads(r.data)["channels"][channel]["version"].split(".")[0]
r = http.request(
"GET",
"https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json",
Expand Down
13 changes: 6 additions & 7 deletions scripts/update_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ def get_chrome_milestone():

r = http.request(
"GET",
f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux",
"https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json",
)
all_versions = json.loads(r.data)
# use the same milestone for all Chrome releases, so pick the lowest
milestones = [version["milestone"] for version in all_versions if version["milestone"]]
if not milestones:
raise ValueError(f"No Chrome versions with milestones found for channel '{channel}'")
milestone = min(milestones)
milestone = json.loads(r.data)["channels"][channel]["version"].split(".")[0]
r = http.request(
"GET",
"https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json",
Expand All @@ -49,6 +44,8 @@ def get_chrome_milestone():

def fetch_and_save(url, file_path):
response = http.request("GET", url)
if response.status != 200:
raise ValueError(f"Fetch failed (HTTP {response.status}): {url}")
with open(file_path, "wb") as file:
file.write(response.data)

Expand Down Expand Up @@ -79,6 +76,8 @@ def flatten_browser_pdl(file_path, chrome_version):
for domain_file in includes:
url = base_url + domain_file
response = http.request("GET", url)
if response.status != 200:
raise ValueError(f"Fetch failed (HTTP {response.status}): {url}")
concatenated += response.data.decode("utf-8") + "\n"
# Overwrite the file with version block + concatenated domains
with open(file_path, "w") as file:
Expand Down