Skip to content

Commit 35247d1

Browse files
improve code
Signed-off-by: alokgoswami-ag <alok.goswami@ibm.com>
1 parent 5195100 commit 35247d1

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
STABLE_RELEASE_URL = "https://ppc64le.ocp.releases.ci.openshift.org/releasestream/4-stable-ppc64le/release/"
44
DEV_PREVIEW_RELEASE_URL = "https://ppc64le.ocp.releases.ci.openshift.org/releasestream/4-dev-preview-ppc64le/release/"
55
HYPERVISOR_CONNECTION_ERROR = "failed to connect to the hypervisor"
6+
RELEASE_BASE_URL = "https://ppc64le.ocp.releases.ci.openshift.org"

monitor.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,24 @@ def fetch_release_date(release):
3535
if p_ele:
3636
if "Created:" in p_ele:
3737
start_date = p_ele.split(" ")[1]+" "+p_ele.split(" ")[2]
38-
break
39-
else:
40-
prefix, number = release.rsplit(".", 1)
41-
prev_version = prefix + "." + str(int(number) - 1)
42-
changelog_url = f"https://ppc64le.ocp.releases.ci.openshift.org/changelog?from={prev_version}&to={release}"
43-
changelog_resp = requests.get(changelog_url, verify=False, timeout=15)
44-
if changelog_resp.status_code == 200:
45-
lines = changelog_resp.text.splitlines()
46-
for line in lines:
47-
if "Created:" in line:
48-
start_date = line.split(" ")[1]+" "+line.split(" ")[2]
38+
return start_date
39+
form = soup.find("form", {"method": "GET"})
40+
if form:
41+
a_tag = form.find("a", href=True)
42+
if a_tag and "changelog" in a_tag["href"]:
43+
changelog_url = constants.RELEASE_BASE_URL + a_tag["href"]
44+
changelog_resp = requests.get(changelog_url, verify=False, timeout=15)
45+
if changelog_resp.status_code == 200:
46+
lines = changelog_resp.text.splitlines()
47+
for line in lines:
48+
if "Created:" in line:
49+
parts = line.split()
50+
if len(parts) >= 3:
51+
start_date = parts[1] + " " + parts[2]
4952
return start_date
50-
51-
return start_date
53+
else:
54+
print(f"Failed to get the changelog page.")
55+
sys.exit(1)
5256
else:
5357
print(f"Failed to get the release page. {response.text}")
5458
sys.exit(1)

0 commit comments

Comments
 (0)