OLD | NEW |
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' |
| 15 FIREFOX_URL = BASE_URL + '/firefox_versions.json' |
| 16 THUNDERBIRD_URL = BASE_URL + '/thunderbird_versions.json' |
| 17 SEAMONKEY_URL = 'http://www.seamonkey-project.org/seamonkey_versions.json' |
14 | 18 |
15 CHROME_UPDATE_XML = '''\ | 19 CHROME_UPDATE_XML = '''\ |
16 <?xml version="1.0" encoding="UTF-8"?> | 20 <?xml version="1.0" encoding="UTF-8"?> |
17 <request protocol="3.0" ismachine="0"> | 21 <request protocol="3.0" ismachine="0"> |
18 <os platform="win" version="99" arch="x64"/> | 22 <os platform="win" version="99" arch="x64"/> |
19 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}"> | 23 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}"> |
20 <updatecheck/> | 24 <updatecheck/> |
21 </app> | 25 </app> |
22 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-beta-multi-chrome"
> | 26 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-beta-multi-chrome"
> |
23 <updatecheck/> | 27 <updatecheck/> |
24 </app> | 28 </app> |
25 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-dev-multi-chrome"> | 29 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-dev-multi-chrome"> |
26 <updatecheck/> | 30 <updatecheck/> |
27 </app> | 31 </app> |
28 </request>''' | 32 </request>''' |
29 | 33 |
30 cache = {} | 34 cache = {} |
31 | 35 |
32 | 36 |
33 def get_mozilla_version(product, origin_version, channel, | 37 def get_json_versions(product_url): |
34 minor=False, subdomain='aus4', origin_build='-', | 38 response = urllib.urlopen(product_url) |
35 attribute='appVersion', platform='WINNT_x86-msvc'): | |
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: | 39 try: |
45 doc = minidom.parse(response) | 40 doc = json.load(response) |
| 41 except json.ValueError: |
| 42 print 'URL: %s not returning json object'.format(product_url) |
46 finally: | 43 finally: |
47 response.close() | 44 response.close() |
48 | 45 |
49 updates = doc.getElementsByTagName('update') | 46 for key, value in doc.iteritems(): |
50 if not updates: | 47 if value: |
51 raise Exception('No updates for %s in %s channel' % (product, channel)) | 48 match = re.search(r'^(\d+)(?:\.\d+)?', value) |
52 full_version = updates[0].getAttribute(attribute) | 49 if match: |
53 | 50 doc[key] = match.group(0) |
54 match = re.search(r'^(\d+)(?:\.\d+)?', full_version) | 51 return doc |
55 if minor: | |
56 return match.group(0) | |
57 return match.group(1) | |
58 | 52 |
59 | 53 |
60 def get_mozilla_versions(product, origin_version, release_minor=False): | 54 def get_firefox_versions(): |
| 55 versions = get_json_versions(FIREFOX_URL) |
61 return { | 56 return { |
62 'current': get_mozilla_version(product, origin_version, 'release', relea
se_minor), | 57 'current': versions['LATEST_FIREFOX_VERSION'], |
| 58 'unreleased': [ |
| 59 versions['LATEST_FIREFOX_DEVEL_VERSION'], |
| 60 versions['FIREFOX_AURORA'], |
| 61 versions['FIREFOX_NIGHTLY'], |
| 62 ] |
| 63 } |
| 64 |
| 65 |
| 66 def get_thunderbird_versions(): |
| 67 tbird_versions = get_json_versions(THUNDERBIRD_URL) |
| 68 firefox_versions = get_json_versions(FIREFOX_URL) |
| 69 return { |
| 70 'current': tbird_versions['LATEST_THUNDERBIRD_VERSION'], |
63 'unreleased': [ | 71 'unreleased': [ |
64 get_mozilla_version(product, origin_version, 'beta'), | 72 tbird_versions['LATEST_THUNDERBIRD_DEVEL_VERSION'], |
65 get_mozilla_version(product, origin_version, 'aurora'), | 73 tbird_versions['LATEST_THUNDERBIRD_ALPHA_VERSION'], |
66 get_mozilla_version(product, origin_version, 'nightly'), | 74 firefox_versions['FIREFOX_NIGHTLY'], |
67 ] | 75 ] |
68 } | 76 } |
69 | 77 |
70 BROWSERS['firefox'] = lambda: get_mozilla_versions('Firefox', '37.0') | 78 BROWSERS['firefox'] = lambda: get_firefox_versions() |
71 BROWSERS['thunderbird'] = lambda: get_mozilla_versions('Thunderbird', '31.0', Tr
ue) | 79 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 | 80 |
78 | 81 |
79 def get_seamonkey_versions(): | 82 def get_seamonkey_versions(): |
| 83 seamonkey_versions = get_json_versions(SEAMONKEY_URL) |
80 versions = { | 84 versions = { |
81 'current': get_seamonkey_version('2.32', '20150112201917', 'release'), | 85 'current': seamonkey_versions['LATEST_SEAMONKEY_VERSION'], |
82 'unreleased': [get_seamonkey_version('2.32', '20150101215737', 'beta')] | 86 'unreleased': [ |
| 87 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'], |
| 88 seamonkey_versions['LATEST_SEAMONKEY_TESTING_VERSION'], |
| 89 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'], |
| 90 ] |
83 } | 91 } |
84 | 92 |
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 | 93 return versions |
96 | 94 |
97 BROWSERS['seamonkey'] = get_seamonkey_versions | 95 BROWSERS['seamonkey'] = get_seamonkey_versions |
98 | 96 |
99 | 97 |
100 def get_chrome_version(manifest): | 98 def get_chrome_version(manifest): |
101 return manifest.getAttribute('version').split('.')[0] | 99 return manifest.getAttribute('version').split('.')[0] |
102 | 100 |
103 | 101 |
104 def get_chrome_versions(): | 102 def get_chrome_versions(): |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 file.seek(0) | 243 file.seek(0) |
246 json.dump(persistent_cache, file) | 244 json.dump(persistent_cache, file) |
247 file.truncate() | 245 file.truncate() |
248 | 246 |
249 if not versions['previous']: | 247 if not versions['previous']: |
250 logging.warning("Couldn't determine previous browser version, " | 248 logging.warning("Couldn't determine previous browser version, " |
251 'please set %s.previous in %s', browser, filename) | 249 'please set %s.previous in %s', browser, filename) |
252 | 250 |
253 cache[browser] = versions | 251 cache[browser] = versions |
254 return versions | 252 return versions |
OLD | NEW |