forked from GoogleChrome/chromium-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule.py
111 lines (91 loc) · 3.35 KB
/
schedule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from __future__ import division
from __future__ import print_function
# -*- coding: utf-8 -*-
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__author__ = 'ericbidelman@chromium.org (Eric Bidelman)'
import json
import logging
import os
import ramcache
from google.appengine.api import urlfetch
from google.appengine.api import users
import common
import models
import settings
import util
SCHEDULE_CACHE_TIME = 60 * 60 # 1 hour
def fetch_chrome_release_info(version):
key = 'chromerelease|%s' % version
data = ramcache.get(key)
if data is None:
url = ('https://chromiumdash.appspot.com/fetch_milestone_schedule?'
'mstone=%s' % version)
result = urlfetch.fetch(url, deadline=60)
if result.status_code == 200:
try:
logging.info('result.content is:\n%s', result.content)
result_json = json.loads(result.content)
if 'mstones' in result_json:
data = result_json['mstones'][0]
del data['owners']
del data['feature_freeze']
del data['ldaps']
ramcache.set(key, data, time=SCHEDULE_CACHE_TIME)
except ValueError:
pass # Handled by next statement
if not data:
data = {
'stable_date': None,
'earliest_beta': None,
'latest_beta': None,
'mstone': version,
'version': version,
}
# Note: we don't put placeholder data into ramcache.
return data
def construct_chrome_channels_details():
omaha_data = util.get_omaha_data()
channels = {}
win_versions = omaha_data[0]['versions']
for v in win_versions:
channel = v['channel']
major_version = int(v['version'].split('.')[0])
channels[channel] = fetch_chrome_release_info(major_version)
channels[channel]['version'] = major_version
# Adjust for the brief period after next miletone gets promted to stable/beta
# channel and their major versions are the same.
if channels['stable']['version'] == channels['beta']['version']:
new_beta_version = channels['stable']['version'] + 1
channels['beta'] = fetch_chrome_release_info(new_beta_version)
channels['beta']['version'] = new_beta_version
new_dev_version = channels['beta']['version'] + 1
channels['dev'] = fetch_chrome_release_info(new_dev_version)
channels['dev']['version'] = new_dev_version
return channels
class ScheduleHandler(common.FlaskHandler):
TEMPLATE_PATH = 'schedule.html'
def get_template_data(self):
user = users.get_current_user()
features = models.Feature.get_chronological(
show_unlisted=self.user_can_edit(user))
template_data = {
'features': json.dumps(features),
'channels': json.dumps(construct_chrome_channels_details(),
indent=4)
}
return template_data
app = common.FlaskApplication([
('/features/schedule', ScheduleHandler),
], debug=settings.DEBUG)