Compare commits
2 Commits
cd13c8b130
...
a27348508c
Author | SHA1 | Date | |
---|---|---|---|
a27348508c | |||
2076cf2ce9 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
__pycache__/
|
||||||
|
.py[co]
|
||||||
|
|
0
__init__.py
Normal file
0
__init__.py
Normal file
38
fedora_schedule.py
Normal file
38
fedora_schedule.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user