2024-02-13 01:01:16 +00:00
|
|
|
import time
|
|
|
|
import requests
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
class FedoraSchedule():
|
|
|
|
def __init__(self, release_version=""):
|
|
|
|
self.release_version = str(release_version)
|
|
|
|
self.schedule_url = "https://fedorapeople.org/groups/schedule"
|
2024-02-13 23:02:43 +00:00
|
|
|
self.schedule_tasks = self._get_schedule()
|
2024-02-13 01:01:16 +00:00
|
|
|
|
|
|
|
def _parse_tasks(self, tasks, tasks_so_far=[]):
|
|
|
|
for _tasks in tasks:
|
|
|
|
if _tasks['_level'] < 3:
|
|
|
|
self._parse_tasks(_tasks['tasks'], tasks_so_far)
|
|
|
|
else:
|
|
|
|
if 'tasks' in _tasks.keys():
|
|
|
|
self._parse_tasks(_tasks['tasks'], tasks_so_far)
|
|
|
|
tasks_so_far.append(_tasks)
|
|
|
|
return tasks_so_far
|
|
|
|
|
2024-02-13 23:02:43 +00:00
|
|
|
def _get_schedule(self):
|
2024-02-13 01:01:16 +00:00
|
|
|
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)
|
|
|
|
tasks = self._parse_tasks(schedule_json['tasks'])
|
|
|
|
return tasks
|
|
|
|
|
|
|
|
def current_state(self):
|
|
|
|
state = ""
|
|
|
|
today = int(time.strftime("%s", time.gmtime()))
|
2024-02-13 23:02:43 +00:00
|
|
|
tasks = self.schedule_tasks
|
2024-02-13 01:01:16 +00:00
|
|
|
for task in tasks:
|
|
|
|
if int(task['start']) < today and today < int(task ['end']):
|
|
|
|
state = task['name']
|
|
|
|
return state
|
|
|
|
|
2024-02-13 23:02:43 +00:00
|
|
|
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']
|
2024-02-13 01:01:16 +00:00
|
|
|
|