39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
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"
|
|
|
|
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
|
|
|
|
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"
|
|
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()))
|
|
tasks = self.get_schedule()
|
|
|
|
for task in tasks:
|
|
if int(task['start']) < today and today < int(task ['end']):
|
|
state = task['name']
|
|
|
|
return state
|
|
|
|
|