Skip to content

Commit 7021939

Browse files
committed
Update logic to account for skipped builds
1 parent ebe86ba commit 7021939

File tree

1 file changed

+51
-50
lines changed

1 file changed

+51
-50
lines changed

collect_executables.py

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from bs4 import BeautifulSoup
1515

1616
GECKO_API_URL = "https://api.github.com/repos/mozilla/geckodriver/releases/latest"
17-
BACKSTOP = "141.0b1"
17+
BACKSTOP = "135.0b9"
1818
NUMBER_ONLY = False
1919

2020

@@ -136,57 +136,58 @@ def get_gd_platform():
136136
else:
137137
# Anything but devedition
138138

139-
# candidate_exists = True
140-
# this_beta = BACKSTOP
141-
# while candidate_exists:
142-
# (major, minor_beta) = this_beta.split(".")
143-
# (minor, beta) = minor_beta.split("b")
144-
# major = int(major)
145-
# minor = int(minor)
146-
# beta = int(beta)
147-
148-
# next_major = f"{major + 1}.0b1"
149-
# fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_major}-candidates/"
150-
# rs = requests.get(fx_download_dir_url)
151-
# if rs.status_code < 300:
152-
# latest_beta_ver = next_major
153-
# this_beta = next_major
154-
# continue
155-
156-
# next_minor = f"{major}.{minor + 1}b1"
157-
# fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_minor}-candidates/"
158-
# rs = requests.get(fx_download_dir_url)
159-
# if rs.status_code < 300:
160-
# latest_beta_ver = next_minor
161-
# this_beta = next_minor
162-
# continue
163-
164-
# next_beta = f"{major}.{minor}b{beta + 1}"
165-
# fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_beta}-candidates/"
166-
# rs = requests.get(fx_download_dir_url)
167-
# if rs.status_code < 300:
168-
# latest_beta_ver = next_beta
169-
# this_beta = next_beta
170-
# continue
171-
172-
# candidate_exists = False
139+
candidate_exists = True
140+
this_beta = BACKSTOP
141+
while candidate_exists:
142+
(major, minor_beta) = this_beta.split(".")
143+
(minor, beta) = minor_beta.split("b")
144+
major = int(major)
145+
minor = int(minor)
146+
beta = int(beta)
147+
148+
next_major = f"{major + 1}.0b1"
149+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_major}-candidates/"
150+
rs = requests.get(fx_download_dir_url)
151+
if rs.status_code < 300:
152+
latest_beta_ver = next_major
153+
this_beta = next_major
154+
continue
155+
156+
next_minor = f"{major}.{minor + 1}b1"
157+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_minor}-candidates/"
158+
rs = requests.get(fx_download_dir_url)
159+
if rs.status_code < 300:
160+
latest_beta_ver = next_minor
161+
this_beta = next_minor
162+
continue
163+
164+
next_beta = f"{major}.{minor}b{beta + 1}"
165+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_beta}-candidates/"
166+
rs = requests.get(fx_download_dir_url)
167+
if rs.status_code < 300:
168+
latest_beta_ver = next_beta
169+
this_beta = next_beta
170+
continue
171+
172+
candidate_exists = False
173173

174174
# Look for the latest build
175-
status = 200
176-
build = 2
177-
latest_beta_ver = BACKSTOP
178-
while status < 400 and build < 20:
179-
build += 1
180-
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{latest_beta_ver}-candidates/build{build}/"
181-
182-
# Fetch the page
183-
response = requests.get(fx_download_dir_url)
184-
status = response.status_code
185-
186-
# Correct build is the last one that didn't 404
187-
build -= 1
188-
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{latest_beta_ver}-candidates/build{build}/{get_fx_platform()}/{language}/"
189-
175+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{latest_beta_ver}-candidates/"
176+
response = requests.get(fx_download_dir_url)
177+
build = 1
178+
if response.status_code < 300:
179+
soup = BeautifulSoup(response.text, "html.parser")
180+
executable_name = ""
181+
# Extract the text of each line
182+
for line in soup.find_all("a"):
183+
line_text = line.getText().split(".")
184+
if not line_text[0]:
185+
continue
186+
# Get the executable name
187+
build = max(int(line_text[0][-2]), build)
188+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{latest_beta_ver}-candidates/build{build}/{get_fx_platform()}/{language}/"
189+
190+
# Get the corresponding executable
190191
response = requests.get(fx_download_dir_url)
191192
status = response.status_code
192193
response_text = None

0 commit comments

Comments
 (0)