diff --git a/src/common/dates.py b/src/common/dates.py index e2e1fbe4..17c71176 100644 --- a/src/common/dates.py +++ b/src/common/dates.py @@ -54,6 +54,7 @@ def parse_datetime(text: str, formats: list[str] = frozenset([ "%Y-%m-%dT%H:%M:%S.%f%z", # 2023-05-01T08:32:34.123456Z "%Y/%m/%d %H:%M:%S", # 2023/05/01 08:32:34 "%a %d %b %Y %H:%M:%S %Z", # Wed, 01 Jan 2020 00:00:00 GMT + "%Y%m%d%H%M%S", # 20230501083234 ]), to_utc: bool = True) -> datetime: """Parse a given text representing a datetime using a list of formats, optionally converting it to UTC. diff --git a/src/red-hat-jboss-eap-7.py b/src/red-hat-jboss-eap-7.py new file mode 100644 index 00000000..b31894c8 --- /dev/null +++ b/src/red-hat-jboss-eap-7.py @@ -0,0 +1,37 @@ +import logging + +from bs4 import BeautifulSoup +from common import dates, http, releasedata + +"""Fetches RedHat JBoss EAP version data for JBoss 7""" + +with releasedata.ProductData("red-hat-jboss-eap") as product_data: + response = http.fetch_url("https://access.redhat.com/articles/2332721") + soup = BeautifulSoup(response.text, features="html5lib") + + for h4 in soup.find_all("h4"): + title = h4.get_text(strip=True) + if not title.startswith("7."): + continue + + release = title[:3] + version_table = h4.find_next("table") + if not version_table: + logging.warning(f"Version table not found for {title}") + continue + + for (i, row) in enumerate(version_table.find_all("tr")): + if i == 0: # Skip the first row (header) + continue + + columns = row.find_all("td") + # Get the version name without the content of the tag, if present + name_str = ''.join([content for content in columns[0].contents if isinstance(content, str)]).strip() + date_str = columns[1].text.strip() + + if date_str == "TBD": # Placeholder for a future release + continue + + name = name_str.replace("GA", "Update 0").replace("Update ", release + ".") + date = dates.parse_date(date_str) + product_data.declare_version(name, date) diff --git a/src/red-hat-jboss-eap-8.py b/src/red-hat-jboss-eap-8.py new file mode 100644 index 00000000..545582e2 --- /dev/null +++ b/src/red-hat-jboss-eap-8.py @@ -0,0 +1,20 @@ +import re +from xml.dom.minidom import parseString + +from common import dates, http, releasedata + +"""Fetches the latest RedHat JBoss EAP version data for JBoss 8.0""" + +with releasedata.ProductData("red-hat-jboss-eap") as product_data: + response = http.fetch_url("https://maven.repository.redhat.com/ga/org/jboss/eap/channels/eap-8.0/maven-metadata.xml") + + xml = parseString(response.text) + versioning = xml.getElementsByTagName("metadata")[0].getElementsByTagName("versioning")[0] + + latest_str = versioning.getElementsByTagName("latest")[0].firstChild.nodeValue + latest_name = "8.0." + re.match(r"^..(.*)\.GA", latest_str).group(1) + + latest_date_str = versioning.getElementsByTagName("lastUpdated")[0].firstChild.nodeValue + latest_date = dates.parse_datetime(latest_date_str) + + product_data.declare_version(latest_name, latest_date)