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: Fix regex, add error handling Created Aug. 16, 2016, 6:44 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_json_versions(product):
34 minor=False, subdomain='aus4', origin_build='-', 34 urls = {
Vasily Kuznetsov 2016/08/22 17:51:55 This dict seems somewhat redundant here. Wouldn't
Jon Sonesen 2016/08/29 13:15:39 So rather than a constant dict just have the funct
35 attribute='appVersion', platform='WINNT_x86-msvc'): 35 'Firefox':
36 response = urllib.urlopen('https://%s.mozilla.org/update/3/%s/%s/%s/%s/en-US /%s/-/default/default/update.xml?force=1' % ( 36 'https://product-details.mozilla.org/1.0/firefox_versions.json',
37 subdomain, 37 'Thunderbird':
38 product, 38 'https://product-details.mozilla.org/1.0/thunderbird_versions.json',
39 origin_version, 39 'Seamonkey':
40 origin_build, 40 'http://www.seamonkey-project.org/seamonkey_versions.json'
41 platform, 41 }
42 channel 42 response = urllib.urlopen(urls[product])
43 ))
44 try: 43 try:
45 doc = minidom.parse(response) 44 doc = json.load(response)
45 except json.ValueError:
46 print 'URL: %s not returning json object'.format(urls[product])
46 finally: 47 finally:
47 response.close() 48 response.close()
48 49
49 updates = doc.getElementsByTagName('update') 50 for key, value in doc.iteritems():
50 if not updates: 51 if value:
51 raise Exception('No updates for %s in %s channel' % (product, channel)) 52 doc[key] = re.search(r'^(\d+)(?:\.\d+)?', value).group(0)
Vasily Kuznetsov 2016/08/22 17:51:55 Isn't this a bit fragile? What if the regex doesn'
Jon Sonesen 2016/08/29 13:15:39 I agree that it is fragile...but also I thought we
52 full_version = updates[0].getAttribute(attribute) 53 return doc
53
54 match = re.search(r'^(\d+)(?:\.\d+)?', full_version)
55 if minor:
56 return match.group(0)
57 return match.group(1)
58 54
59 55
60 def get_mozilla_versions(product, origin_version, release_minor=False): 56 def get_firefox_versions():
57 versions = get_json_versions('Firefox')
61 return { 58 return {
62 'current': get_mozilla_version(product, origin_version, 'release', relea se_minor), 59 'current': versions['LATEST_FIREFOX_VERSION'],
60 'unreleased': [
61 versions['LATEST_FIREFOX_DEVEL_VERSION'],
Vasily Kuznetsov 2016/08/22 17:51:55 It would be nice to give more friendly error messa
Jon Sonesen 2016/08/29 13:15:39 I thought we decided not to so the build 'fails lo
62 versions['FIREFOX_AURORA'],
63 versions['FIREFOX_NIGHTLY'],
64 ]
65 }
66
67
68 def get_thunderbird_versions():
69 versions = get_json_versions('Thunderbird')
70 firefox_versions = get_json_versions('Firefox')
71 return {
72 'current': versions['LATEST_THUNDERBIRD_VERSION'],
63 'unreleased': [ 73 'unreleased': [
64 get_mozilla_version(product, origin_version, 'beta'), 74 versions['LATEST_THUNDERBIRD_DEVEL_VERSION'],
65 get_mozilla_version(product, origin_version, 'aurora'), 75 versions['LATEST_THUNDERBIRD_ALPHA'],
Vasily Kuznetsov 2016/08/22 17:51:55 I think this should be LATEST_THUNDERBIRD_ALPHA_VE
Jon Sonesen 2016/08/29 13:15:39 you're right....dang haha
66 get_mozilla_version(product, origin_version, 'nightly'), 76 firefox_versions['FIREFOX_NIGHTLY'],
67 ] 77 ]
68 } 78 }
69 79
70 BROWSERS['firefox'] = lambda: get_mozilla_versions('Firefox', '37.0') 80 BROWSERS['firefox'] = lambda: get_firefox_versions()
71 BROWSERS['thunderbird'] = lambda: get_mozilla_versions('Thunderbird', '31.0', Tr ue) 81 BROWSERS['thunderbird'] = lambda: get_thunderbird_versions()
72
73
74 def get_seamonkey_version(origin_version, origin_build, channel, **kw):
75 return get_mozilla_version('SeaMonkey', origin_version, channel, True,
76 'aus2-community', origin_build, 'version', **kw)
77 82
78 83
79 def get_seamonkey_versions(): 84 def get_seamonkey_versions():
85 seamonkey_versions = get_json_versions('Seamonkey')
80 versions = { 86 versions = {
81 'current': get_seamonkey_version('2.32', '20150112201917', 'release'), 87 'current': seamonkey_versions['LATEST_SEAMONKEY_VERSION'],
82 'unreleased': [get_seamonkey_version('2.32', '20150101215737', 'beta')] 88 'unreleased': [
89 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'],
90 seamonkey_versions['LATEST_SEAMONKEY_TESTING_VERSION'],
91 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'],
92 ]
83 } 93 }
84 94
85 # Aurora and Nightly builds for Windows are permantently broken.
86 # Occasionally, builds for other platforms are broken as well.
87 # https://bugzilla.mozilla.org/show_bug.cgi?id=1086553
88 for channel in ('aurora', 'nightly'):
89 try:
90 version = get_seamonkey_version('2.32', '-', channel, platform='Linu x_x86-gcc3')
91 except Exception:
92 continue
93 versions['unreleased'].append(version)
94
95 return versions 95 return versions
96 96
97 BROWSERS['seamonkey'] = get_seamonkey_versions 97 BROWSERS['seamonkey'] = get_seamonkey_versions
98 98
99 99
100 def get_chrome_version(manifest): 100 def get_chrome_version(manifest):
101 return manifest.getAttribute('version').split('.')[0] 101 return manifest.getAttribute('version').split('.')[0]
102 102
103 103
104 def get_chrome_versions(): 104 def get_chrome_versions():
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 file.seek(0) 245 file.seek(0)
246 json.dump(persistent_cache, file) 246 json.dump(persistent_cache, file)
247 file.truncate() 247 file.truncate()
248 248
249 if not versions['previous']: 249 if not versions['previous']:
250 logging.warning("Couldn't determine previous browser version, " 250 logging.warning("Couldn't determine previous browser version, "
251 'please set %s.previous in %s', browser, filename) 251 'please set %s.previous in %s', browser, filename)
252 252
253 cache[browser] = versions 253 cache[browser] = versions
254 return versions 254 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