Skip to content

Commit 438f6a7

Browse files
authored
Ben/fix collect exec (#493)
* use bs4 to collect link * use bs4 and well-formed deved url
1 parent c94f5a7 commit 438f6a7

File tree

1 file changed

+60
-55
lines changed

1 file changed

+60
-55
lines changed

collect_executables.py

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ def get_gd_platform():
103103
language = "en-US"
104104

105105
if channel == "-devedition":
106+
# Devedition has special requirements as it's testing a release
107+
106108
this_devedition = BACKSTOP
107109
fx_download_dir_url = (
108110
"https://archive.mozilla.org/pub/devedition/releases/135.0b5/"
@@ -121,64 +123,64 @@ def get_gd_platform():
121123
fx_download_dir_url = next_candidate
122124

123125
devedition_version = fx_download_dir_url.split("/")[-2]
124-
if NUMBER_ONLY:
125-
print(devedition_version)
126-
else:
127-
print(
128-
f"{fx_download_dir_url}{get_fx_platform()}/{language}/Firefox%20{devedition_version}.{get_fx_executable_extension()}"
129-
)
130-
exit()
131-
132-
candidate_exists = True
133-
this_beta = BACKSTOP
134-
while candidate_exists:
135-
(major, minor_beta) = this_beta.split(".")
136-
(minor, beta) = minor_beta.split("b")
137-
major = int(major)
138-
minor = int(minor)
139-
beta = int(beta)
140-
141-
next_major = f"{major + 1}.0b1"
142-
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_major}-candidates/build1/"
143-
rs = requests.get(fx_download_dir_url)
144-
if rs.status_code < 300:
145-
latest_beta_ver = next_major
146-
this_beta = next_major
147-
continue
148-
149-
next_minor = f"{major}.{minor + 1}b1"
150-
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_minor}-candidates/build1/"
151-
rs = requests.get(fx_download_dir_url)
152-
if rs.status_code < 300:
153-
latest_beta_ver = next_minor
154-
this_beta = next_minor
155-
continue
126+
fx_download_dir_url = f"{fx_download_dir_url}{get_fx_platform()}/{language}/"
156127

157-
next_beta = f"{major}.{minor}b{beta + 1}"
158-
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_beta}-candidates/build1/"
159-
rs = requests.get(fx_download_dir_url)
160-
if rs.status_code < 300:
161-
latest_beta_ver = next_beta
162-
this_beta = next_beta
163-
continue
164-
165-
candidate_exists = False
128+
else:
129+
# Anything but devedition
166130

167-
status = 200
168-
build = 0
169-
while status < 400 and build < 20:
170-
build += 1
171-
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{latest_beta_ver}-candidates/build{build}/"
131+
candidate_exists = True
132+
this_beta = BACKSTOP
133+
while candidate_exists:
134+
(major, minor_beta) = this_beta.split(".")
135+
(minor, beta) = minor_beta.split("b")
136+
major = int(major)
137+
minor = int(minor)
138+
beta = int(beta)
139+
140+
next_major = f"{major + 1}.0b1"
141+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_major}-candidates/build1/"
142+
rs = requests.get(fx_download_dir_url)
143+
if rs.status_code < 300:
144+
latest_beta_ver = next_major
145+
this_beta = next_major
146+
continue
147+
148+
next_minor = f"{major}.{minor + 1}b1"
149+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_minor}-candidates/build1/"
150+
rs = requests.get(fx_download_dir_url)
151+
if rs.status_code < 300:
152+
latest_beta_ver = next_minor
153+
this_beta = next_minor
154+
continue
155+
156+
next_beta = f"{major}.{minor}b{beta + 1}"
157+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{next_beta}-candidates/build1/"
158+
rs = requests.get(fx_download_dir_url)
159+
if rs.status_code < 300:
160+
latest_beta_ver = next_beta
161+
this_beta = next_beta
162+
continue
163+
164+
candidate_exists = False
165+
166+
status = 200
167+
build = 0
168+
while status < 400 and build < 20:
169+
build += 1
170+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{latest_beta_ver}-candidates/build{build}/"
171+
172+
# Fetch the page
173+
response = requests.get(fx_download_dir_url)
174+
status = response.status_code
172175

173-
# Fetch the page
174-
response = requests.get(fx_download_dir_url)
175-
status = response.status_code
176+
# Correct build is the last one that didn't 404
177+
build -= 1
178+
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{latest_beta_ver}-candidates/build{build}/{get_fx_platform()}/{language}/"
176179

177-
# Correct build is the last one that didn't 404
178-
build -= 1
179-
fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/candidates/{latest_beta_ver}-candidates/build{build}/{get_fx_platform()}/{language}/"
180+
print(f"trying {fx_download_dir_url}")
180181
response = requests.get(fx_download_dir_url)
181182
status = response.status_code
183+
print(f"response code: {status}")
182184
response_text = None
183185
for _ in range(3):
184186
if status < 300:
@@ -206,8 +208,11 @@ def get_gd_platform():
206208

207209
fx_download_executable_url = rf"{fx_download_dir_url}{executable_name}"
208210
if NUMBER_ONLY:
209-
number_cand = fx_download_dir_url.split("/")[6]
210-
number = number_cand.split("-")[0]
211-
print(f"{number}-build{build}")
211+
if channel == "-devedition":
212+
print(devedition_version)
213+
else:
214+
number_cand = fx_download_dir_url.split("/")[6]
215+
number = number_cand.split("-")[0]
216+
print(f"{number}-build{build}")
212217
else:
213218
print(fx_download_executable_url)

0 commit comments

Comments
 (0)