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

Side by Side Diff: globals/get_browser_versions.py

Issue 29515558: Issue 5496 - Use omahaproxy to get chrome-versions (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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 CHROME_UPDATE_XML = '''\
20 <?xml version="1.0" encoding="UTF-8"?>
21 <request protocol="3.0" ismachine="0">
22 <os platform="win" version="99" arch="x64"/>
23 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}">
24 <updatecheck/>
25 </app>
26 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-beta-multi-chrome" >
27 <updatecheck/>
28 </app>
29 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-dev-multi-chrome">
30 <updatecheck/>
31 </app>
32 </request>'''
33 19
34 cache = {} 20 cache = {}
35 21
36 22
37 def get_json_versions(product_url): 23 def get_json_versions(product_url):
38 response = urllib.urlopen(product_url) 24 response = urllib.urlopen(product_url)
39 try: 25 try:
40 doc = json.load(response) 26 doc = json.load(response)
41 except json.ValueError: 27 except json.ValueError:
42 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
86 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'], 72 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'],
87 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'], 73 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'],
88 ] 74 ]
89 } 75 }
90 76
91 return versions 77 return versions
92 78
93 BROWSERS['seamonkey'] = get_seamonkey_versions 79 BROWSERS['seamonkey'] = get_seamonkey_versions
94 80
95 81
96 def get_chrome_version(manifest):
97 return manifest.getAttribute('version').split('.')[0]
98
99
100 def get_chrome_versions(): 82 def get_chrome_versions():
101 response = urllib.urlopen('https://tools.google.com/service/update2', CHROME _UPDATE_XML) 83 response = urllib.urlopen(CHROME_URL)
102 try: 84 try:
103 doc = minidom.parse(response) 85 data = json.load(response)
104 finally: 86 finally:
105 response.close() 87 response.close()
106 88
107 manifests = doc.getElementsByTagName('manifest') 89 versions = {
90 x['channel']: x['version'].split('.')[0]
91 for x in data[0]['versions']
92 }
93
108 return { 94 return {
109 'current': get_chrome_version(manifests[0]), 95 'current': versions['stable'],
110 'unreleased': map(get_chrome_version, manifests[1:]) 96 'unreleased': [versions['beta'], versions['dev']],
111 } 97 }
112 98
113 BROWSERS['chrome'] = get_chrome_versions 99 BROWSERS['chrome'] = get_chrome_versions
114 100
115 101
116 def get_opera_version(channel): 102 def get_opera_version(channel):
117 response = urllib.urlopen('https://autoupdate.geo.opera.com/netinstaller/' + channel) 103 response = urllib.urlopen('https://autoupdate.geo.opera.com/netinstaller/' + channel)
118 try: 104 try:
119 spec = json.load(response) 105 spec = json.load(response)
120 finally: 106 finally:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 file.seek(0) 227 file.seek(0)
242 json.dump(persistent_cache, file) 228 json.dump(persistent_cache, file)
243 file.truncate() 229 file.truncate()
244 230
245 if not versions['previous']: 231 if not versions['previous']:
246 logging.warning("Couldn't determine previous browser version, " 232 logging.warning("Couldn't determine previous browser version, "
247 'please set %s.previous in %s', browser, filename) 233 'please set %s.previous in %s', browser, filename)
248 234
249 cache[browser] = versions 235 cache[browser] = versions
250 return versions 236 return versions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld