added release information

This commit is contained in:
Mark McIntyre 2024-02-13 18:02:43 -05:00
parent a27348508c
commit c593ecf065

View File

@ -7,6 +7,7 @@ class FedoraSchedule():
def __init__(self, release_version=""): def __init__(self, release_version=""):
self.release_version = str(release_version) self.release_version = str(release_version)
self.schedule_url = "https://fedorapeople.org/groups/schedule" self.schedule_url = "https://fedorapeople.org/groups/schedule"
self.schedule_tasks = self._get_schedule()
def _parse_tasks(self, tasks, tasks_so_far=[]): def _parse_tasks(self, tasks, tasks_so_far=[]):
for _tasks in tasks: for _tasks in tasks:
@ -18,7 +19,7 @@ class FedoraSchedule():
tasks_so_far.append(_tasks) tasks_so_far.append(_tasks)
return tasks_so_far return tasks_so_far
def get_schedule(self): def _get_schedule(self):
release_schedule_url = f"{self.schedule_url.format(self.release_version)}/f-{self.release_version}/f-{self.release_version}-key.json" release_schedule_url = f"{self.schedule_url.format(self.release_version)}/f-{self.release_version}/f-{self.release_version}-key.json"
schedule_json = json.loads(requests.get(release_schedule_url).content) schedule_json = json.loads(requests.get(release_schedule_url).content)
tasks = self._parse_tasks(schedule_json['tasks']) tasks = self._parse_tasks(schedule_json['tasks'])
@ -27,12 +28,32 @@ class FedoraSchedule():
def current_state(self): def current_state(self):
state = "" state = ""
today = int(time.strftime("%s", time.gmtime())) today = int(time.strftime("%s", time.gmtime()))
tasks = self.get_schedule() tasks = self.schedule_tasks
for task in tasks: for task in tasks:
if int(task['start']) < today and today < int(task ['end']): if int(task['start']) < today and today < int(task ['end']):
state = task['name'] state = task['name']
return state return state
def _get_release(self):
release = {}
release_date = None
tasks = self.schedule_tasks
for task in tasks:
if 'current_final_target_date' in task['slug']:
release_date = time.strftime('%Y-%m-%d', time.gmtime(int(task['end'])))
release = {
'name': task['name'],
'date': release_date
}
return release
def release(self):
release = self._get_release()
return f"{release['name']} is {release['date']}"
def release_date(self):
release = self._get_release()
return release['date']