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