| |
@@ -1,48 +1,68 @@
|
| |
+ #
|
| |
+ # schedule.py - Fedora Release Schedule parsers and utilities for QA Ladning Page
|
| |
+ #
|
| |
+ # Copyright 2020, Red Hat, Inc
|
| |
+ #
|
| |
+ # This program is free software; you can redistribute it and/or modify
|
| |
+ # it under the terms of the GNU General Public License as published by
|
| |
+ # the Free Software Foundation; either version 2 of the License, or
|
| |
+ # (at your option) any later version.
|
| |
+ #
|
| |
+ # This program is distributed in the hope that it will be useful,
|
| |
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| |
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| |
+ # GNU General Public License for more details.
|
| |
+ #
|
| |
+ # You should have received a copy of the GNU General Public License along
|
| |
+ # with this program; if not, write to the Free Software Foundation, Inc.,
|
| |
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
| |
+ #
|
| |
+ # Authors:
|
| |
+ # Frantisek Zatloukal <fzatlouk@redhat.com>
|
| |
+ # Josef Skladanka <jskladan@redhat.com>
|
| |
+ # Lukas Brabec <lbrabec@redhat.com>
|
| |
+
|
| |
import icalendar
|
| |
- import requests
|
| |
import datetime
|
| |
import pytz
|
| |
|
| |
- SCHEDULE_URL = "https://fedorapeople.org/groups/schedule/f-%d/f-%d-key.ics"
|
| |
- RELEASES_URL = "https://getfedora.org/releases.json"
|
| |
-
|
| |
-
|
| |
- def current_stable():
|
| |
- resp = requests.get(RELEASES_URL)
|
| |
- if resp.status_code == 200:
|
| |
- releases = resp.json()
|
| |
- return max([int(r['version']) for r in releases if 'Beta' not in r['version']]) # FIXME
|
| |
- else:
|
| |
- return -1 # FIXME
|
| |
-
|
| |
-
|
| |
- def current_devel():
|
| |
- return current_stable() + 1
|
| |
-
|
| |
+ from oraculum import app
|
| |
+ from oraculum.utils.dashboard_helpers import get_json
|
| |
|
| |
def _is_relevant(summary):
|
| |
- relevant = ['Branch Fedora', 'Beta Freeze starts', 'Beta Release', 'Final Freeze starts', 'Final Release']
|
| |
+ relevant = ['Branch Fedora', 'Beta Freeze', 'Beta Release Public Availability', 'Final Freeze', 'Final Release Public Availability']
|
| |
return any([word in summary for word in relevant])
|
| |
|
| |
|
| |
def get_schedule():
|
| |
+
|
| |
+ # Work around cyclic import
|
| |
+ from oraculum import CACHE
|
| |
+
|
| |
today = datetime.datetime.utcnow()
|
| |
today = today.replace(tzinfo=pytz.UTC)
|
| |
- resp = requests.get(SCHEDULE_URL % (current_devel(), current_devel())) # FIXME
|
| |
+
|
| |
+ releases = CACHE.get("fedora_releases")
|
| |
+ release = releases["branched"] or releases["rawhide"]
|
| |
+
|
| |
+ resp = get_json(app.config["SCHEDULE_URL"] % (release, release), ignore_json_errors=True)
|
| |
data = []
|
| |
- if resp.status_code == 200: # FIXME
|
| |
- ical_raw = icalendar.Calendar.from_ical(resp.text)
|
| |
- for c in ical_raw.walk():
|
| |
- if c.name == "VEVENT":
|
| |
- summary = c.get('summary')
|
| |
- date = c.get('dtstart').dt.astimezone(pytz.UTC)
|
| |
- if _is_relevant(summary):
|
| |
- data.append({
|
| |
- 'summary': summary,
|
| |
- 'date': date.strftime("%d %b %Y"),
|
| |
- 'dtdate': date,
|
| |
- 'current': date <= today # mark all until now as current and clean up later
|
| |
- })
|
| |
+
|
| |
+ if not resp:
|
| |
+ return []
|
| |
+
|
| |
+ ical_raw = icalendar.Calendar.from_ical(resp)
|
| |
+ for c in ical_raw.walk():
|
| |
+ if c.name == "VEVENT":
|
| |
+ summary = c.get('summary')
|
| |
+ date = c.get('dtstart').dt.astimezone(pytz.UTC)
|
| |
+ if _is_relevant(summary):
|
| |
+ data.append({
|
| |
+ 'summary': summary,
|
| |
+ 'date': date.strftime("%d %b %Y"),
|
| |
+ 'dtdate': date,
|
| |
+ 'current': date <= today # mark all until now as current and clean up later
|
| |
+ })
|
| |
|
| |
data = sorted(data, key=lambda c: c['dtdate'])
|
| |
|
| |
So, what happens now, if the response was not 200?