Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: globals/get_browser_versions.py

Issue 29515558: Issue 5496 - Use omahaproxy to get chrome-versions (Closed)
Left Patch Set: Created Aug. 14, 2017, 8:01 a.m.
Right Patch Set: Choose desired version in dict-comprehension Created Aug. 14, 2017, 12:07 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import re 1 import re
2 import os 2 import os
3 import sys 3 import sys
4 import json 4 import json
5 import urllib 5 import urllib
6 import errno 6 import errno
7 import logging 7 import logging
8 import time 8 import time
9 from xml.dom import minidom 9 from xml.dom import minidom
10 10
11 from jinja2 import contextfunction 11 from jinja2 import contextfunction
12 12
13 BROWSERS = {} 13 BROWSERS = {}
14 BASE_URL = 'https://product-details.mozilla.org/1.0' 14 BASE_URL = 'https://product-details.mozilla.org/1.0'
15 FIREFOX_URL = BASE_URL + '/firefox_versions.json' 15 FIREFOX_URL = BASE_URL + '/firefox_versions.json'
16 THUNDERBIRD_URL = BASE_URL + '/thunderbird_versions.json' 16 THUNDERBIRD_URL = BASE_URL + '/thunderbird_versions.json'
17 SEAMONKEY_URL = 'http://www.seamonkey-project.org/seamonkey_versions.json' 17 SEAMONKEY_URL = 'http://www.seamonkey-project.org/seamonkey_versions.json'
18 CHROME_URL = 'https://omahaproxy.appspot.com/all.json?os=win' 18 CHROME_URL = 'https://omahaproxy.appspot.com/all.json?os=win'
saroyanm 2017/08/14 14:26:10 The URL mentioned in the Issue tracker doesn't inc
Sebastian Noack 2017/08/14 14:33:30 Note that this is consistent with the old implemen
saroyanm 2017/08/14 14:34:48 Acknowledged.
19 19
20 cache = {} 20 cache = {}
21 21
22 22
23 def get_json_versions(product_url): 23 def get_json_versions(product_url):
24 response = urllib.urlopen(product_url) 24 response = urllib.urlopen(product_url)
25 try: 25 try:
26 doc = json.load(response) 26 doc = json.load(response)
27 except json.ValueError: 27 except json.ValueError:
28 print 'URL: %s not returning json object'.format(product_url) 28 print 'URL: %s not returning json object'.format(product_url)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'], 72 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'],
73 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'], 73 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'],
74 ] 74 ]
75 } 75 }
76 76
77 return versions 77 return versions
78 78
79 BROWSERS['seamonkey'] = get_seamonkey_versions 79 BROWSERS['seamonkey'] = get_seamonkey_versions
80 80
81 81
82 def get_chrome_version(version_info):
83 return version_info['version'].split('.')[0]
84
85
86 def get_chrome_versions(): 82 def get_chrome_versions():
87 response = urllib.urlopen(CHROME_URL) 83 response = urllib.urlopen(CHROME_URL)
88 try: 84 try:
89 data = json.load(response) 85 data = json.load(response)
90 finally: 86 finally:
91 response.close() 87 response.close()
92 88
93 channels = {x['channel']: x for x in data[0]['versions']} 89 versions = {
Sebastian Noack 2017/08/14 11:54:31 It seems the logic can be simplified. All data we
tlucas 2017/08/14 12:08:28 Done.
94 90 x['channel']: x['version'].split('.')[0]
95 return { 91 for x in data[0]['versions']
96 'current': get_chrome_version(channels['stable']), 92 }
97 'unreleased': map( 93
98 get_chrome_version, 94 return {
99 (channels['beta'], channels['dev']) 95 'current': versions['stable'],
100 ), 96 'unreleased': [versions['beta'], versions['dev']],
101 } 97 }
102 98
103 BROWSERS['chrome'] = get_chrome_versions 99 BROWSERS['chrome'] = get_chrome_versions
104 100
105 101
106 def get_opera_version(channel): 102 def get_opera_version(channel):
107 response = urllib.urlopen('https://autoupdate.geo.opera.com/netinstaller/' + channel) 103 response = urllib.urlopen('https://autoupdate.geo.opera.com/netinstaller/' + channel)
108 try: 104 try:
109 spec = json.load(response) 105 spec = json.load(response)
110 finally: 106 finally:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 file.seek(0) 227 file.seek(0)
232 json.dump(persistent_cache, file) 228 json.dump(persistent_cache, file)
233 file.truncate() 229 file.truncate()
234 230
235 if not versions['previous']: 231 if not versions['previous']:
236 logging.warning("Couldn't determine previous browser version, " 232 logging.warning("Couldn't determine previous browser version, "
237 'please set %s.previous in %s', browser, filename) 233 'please set %s.previous in %s', browser, filename)
238 234
239 cache[browser] = versions 235 cache[browser] = versions
240 return versions 236 return versions
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld