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

Side by Side Diff: globals/get_browser_versions.py

Issue 29348818: issue 4087 - Use Mozilla's product-details data to determine current product versions (Closed)
Patch Set: Replace update server calls with json request Created July 28, 2016, 7:45 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
(...skipping 12 matching lines...) Expand all
23 <updatecheck/> 23 <updatecheck/>
24 </app> 24 </app>
25 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-dev-multi-chrome"> 25 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-dev-multi-chrome">
26 <updatecheck/> 26 <updatecheck/>
27 </app> 27 </app>
28 </request>''' 28 </request>'''
29 29
30 cache = {} 30 cache = {}
31 31
32 32
33 def get_mozilla_version(product, origin_version, channel, 33 def get_firefox_version():
34 minor=False, subdomain='aus4', origin_build='-', 34 url = 'https://product-details.mozilla.org/firefox_versions.json'
35 attribute='appVersion', platform='WINNT_x86-msvc'): 35 response = urllib.urlopen(url)
36 response = urllib.urlopen('https://%s.mozilla.org/update/3/%s/%s/%s/%s/en-US /%s/-/default/default/update.xml?force=1' % (
37 subdomain,
38 product,
39 origin_version,
40 origin_build,
41 platform,
42 channel
43 ))
44 try: 36 try:
45 doc = minidom.parse(response) 37 doc = json.loads(response.read())
Sebastian Noack 2016/08/01 16:21:07 Any reason you cannot parse the response lazily?
46 finally: 38 finally:
47 response.close() 39 response.close()
48 40 return doc
49 updates = doc.getElementsByTagName('update')
50 if not updates:
51 raise Exception('No updates for %s in %s channel' % (product, channel))
52 full_version = updates[0].getAttribute(attribute)
53
54 match = re.search(r'^(\d+)(?:\.\d+)?', full_version)
55 if minor:
56 return match.group(0)
57 return match.group(1)
58 41
59 42
60 def get_mozilla_versions(product, origin_version, release_minor=False): 43 def get_firefox_versions():
44 versions = get_firefox_version()
61 return { 45 return {
62 'current': get_mozilla_version(product, origin_version, 'release', relea se_minor), 46 'current': versions['LATEST_FIREFOX_VERSION'],
47 'unreleased': [
48 versions['LATEST_FIREFOX_DEVEL_VERSION'],
49 versions['FIREFOX_AURORA'],
50 versions['FIREFOX_NIGHTLY'],
51 ]
52 }
53
54
55 def get_thunderbird_version():
56 url = 'https://product-details.mozilla.org/thunderbird_versions.json'
57 response = urllib.urlopen(url)
58 try:
59 doc = json.loads(response.read())
60 finally:
61 response.close()
62 return doc
63
64
65 def get_thunderbird_versions():
66 versions = get_thunderbird_version()
67 firefox_versions = get_firefox_version()
68 return {
69 'current': versions['LATEST_THUNDERBIRD_VERSION'],
63 'unreleased': [ 70 'unreleased': [
64 get_mozilla_version(product, origin_version, 'beta'), 71 versions['LATEST_THUNDERBIRD_DEVEL_VERSION'],
65 get_mozilla_version(product, origin_version, 'aurora'), 72 firefox_versions['FIREFOX_AURORA'],
66 get_mozilla_version(product, origin_version, 'nightly'), 73 firefox_versions['FIREFOX_NIGHTLY'],
67 ] 74 ]
68 } 75 }
69 76
70 BROWSERS['firefox'] = lambda: get_mozilla_versions('Firefox', '37.0') 77 BROWSERS['firefox'] = lambda: get_firefox_versions()
71 BROWSERS['thunderbird'] = lambda: get_mozilla_versions('Thunderbird', '31.0', Tr ue) 78 BROWSERS['thunderbird'] = lambda: get_thunderbird_versions()
72 79
73 80
74 def get_seamonkey_version(origin_version, origin_build, channel, **kw): 81 def get_seamonkey_version():
Sebastian Noack 2016/08/01 16:21:07 This code duplication isn't great. How about, inst
75 return get_mozilla_version('SeaMonkey', origin_version, channel, True, 82 url = 'http://www.seamonkey-project.org/seamonkey_versions.json'
76 'aus2-community', origin_build, 'version', **kw) 83 response = urllib.urlopen(url)
84 try:
85 doc = json.loads(response.read())
86 finally:
87 response.close()
88 return doc
77 89
78 90
79 def get_seamonkey_versions(): 91 def get_seamonkey_versions():
80 versions = {
81 'current': get_seamonkey_version('2.32', '20150112201917', 'release'),
82 'unreleased': [get_seamonkey_version('2.32', '20150101215737', 'beta')]
83 }
84
85 # Aurora and Nightly builds for Windows are permantently broken. 92 # Aurora and Nightly builds for Windows are permantently broken.
86 # Occasionally, builds for other platforms are broken as well. 93 # Occasionally, builds for other platforms are broken as well.
87 # https://bugzilla.mozilla.org/show_bug.cgi?id=1086553 94 # https://bugzilla.mozilla.org/show_bug.cgi?id=1086553
88 for channel in ('aurora', 'nightly'): 95 seamonkey_versions = get_seamonkey_version()
89 try: 96 versions = {
90 version = get_seamonkey_version('2.32', '-', channel, platform='Linu x_x86-gcc3') 97 'current': seamonkey_versions['LATEST_SEAMONKEY_VERSION'],
91 except Exception: 98 'unreleased': [
92 continue 99 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'],
93 versions['unreleased'].append(version) 100 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'],
101 seamonkey_versions['LATEST_SEAMONKEY_TESTING_VERSION'],
102 ]
103 }
94 104
95 return versions 105 return versions
96 106
97 BROWSERS['seamonkey'] = get_seamonkey_versions 107 BROWSERS['seamonkey'] = get_seamonkey_versions
98 108
99 109
100 def get_chrome_version(manifest): 110 def get_chrome_version(manifest):
101 return manifest.getAttribute('version').split('.')[0] 111 return manifest.getAttribute('version').split('.')[0]
102 112
103 113
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 file.seek(0) 255 file.seek(0)
246 json.dump(persistent_cache, file) 256 json.dump(persistent_cache, file)
247 file.truncate() 257 file.truncate()
248 258
249 if not versions['previous']: 259 if not versions['previous']:
250 logging.warning("Couldn't determine previous browser version, " 260 logging.warning("Couldn't determine previous browser version, "
251 'please set %s.previous in %s', browser, filename) 261 'please set %s.previous in %s', browser, filename)
252 262
253 cache[browser] = versions 263 cache[browser] = versions
254 return versions 264 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