Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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_json_versions(product): | 37 def get_json_versions(product_url): |
34 urls = { | 38 response = urllib.urlopen(product_url) |
35 'Firefox': | 39 try: |
36 'https://product-details.mozilla.org/firefox_versions.json', | 40 doc = json.load(response) |
Wladimir Palant
2016/08/12 11:40:55
Gotta love it - the URL changed into https://produ
Jon Sonesen
2016/08/16 02:27:54
will update :D
| |
37 'Thunderbird': | 41 except json.ValueError: |
38 'https://product-details.mozilla.org/thunderbird_versions.json', | 42 print 'URL: %s not returning json object'.format(product_url) |
39 'Seamonkey': | 43 finally: |
40 'http://www.seamonkey-project.org/seamonkey_versions.json' | 44 response.close() |
41 } | 45 |
42 response = urllib.urlopen(urls[product]) | 46 for key, value in doc.iteritems(): |
43 try: | 47 if value: |
44 doc = json.load(response.read()) | 48 match = re.search(r'^(\d+)(?:\.\d+)?', value) |
45 finally: | 49 if match: |
46 response.close() | 50 doc[key] = match.group(0) |
47 return doc | 51 return doc |
48 | 52 |
49 | 53 |
50 def get_firefox_versions(): | 54 def get_firefox_versions(): |
51 versions = get_json_versions('Firefox') | 55 versions = get_json_versions(FIREFOX_URL) |
52 return { | 56 return { |
53 'current': versions['LATEST_FIREFOX_VERSION'], | 57 'current': versions['LATEST_FIREFOX_VERSION'], |
54 'unreleased': [ | 58 'unreleased': [ |
55 versions['LATEST_FIREFOX_DEVEL_VERSION'], | 59 versions['LATEST_FIREFOX_DEVEL_VERSION'], |
56 versions['FIREFOX_AURORA'], | 60 versions['FIREFOX_AURORA'], |
57 versions['FIREFOX_NIGHTLY'], | 61 versions['FIREFOX_NIGHTLY'], |
Wladimir Palant
2016/08/12 11:40:55
We need to remove the "a1" and similar suffixes fr
Jon Sonesen
2016/08/16 02:27:54
Just to clarify; do you mean that I should remove
Wladimir Palant
2016/08/16 10:40:17
The code you are replacing here was using r'^(\d+)
Jon Sonesen
2016/08/16 18:46:09
Thank you, also I added a log statement in case th
| |
58 ] | 62 ] |
59 } | 63 } |
60 | 64 |
61 | 65 |
62 def get_thunderbird_versions(): | 66 def get_thunderbird_versions(): |
63 versions = get_json_versions('Thunderbird') | 67 tbird_versions = get_json_versions(THUNDERBIRD_URL) |
64 firefox_versions = get_json_versions('Firefox') | 68 firefox_versions = get_json_versions(FIREFOX_URL) |
65 return { | 69 return { |
66 'current': versions['LATEST_THUNDERBIRD_VERSION'], | 70 'current': tbird_versions['LATEST_THUNDERBIRD_VERSION'], |
67 'unreleased': [ | 71 'unreleased': [ |
68 versions['LATEST_THUNDERBIRD_DEVEL_VERSION'], | 72 tbird_versions['LATEST_THUNDERBIRD_DEVEL_VERSION'], |
69 firefox_versions['FIREFOX_AURORA'], | 73 tbird_versions['LATEST_THUNDERBIRD_ALPHA_VERSION'], |
70 firefox_versions['FIREFOX_NIGHTLY'], | 74 firefox_versions['FIREFOX_NIGHTLY'], |
Wladimir Palant
2016/08/12 11:40:55
There is LATEST_THUNDERBIRD_ALPHA_VERSION in the d
Jon Sonesen
2016/08/16 02:27:54
Will use that instead.
| |
71 ] | 75 ] |
72 } | 76 } |
73 | 77 |
74 BROWSERS['firefox'] = lambda: get_firefox_versions() | 78 BROWSERS['firefox'] = lambda: get_firefox_versions() |
75 BROWSERS['thunderbird'] = lambda: get_thunderbird_versions() | 79 BROWSERS['thunderbird'] = lambda: get_thunderbird_versions() |
76 | 80 |
77 | 81 |
78 def get_seamonkey_versions(): | 82 def get_seamonkey_versions(): |
79 # Aurora and Nightly builds for Windows are permantently broken. | 83 seamonkey_versions = get_json_versions(SEAMONKEY_URL) |
80 # Occasionally, builds for other platforms are broken as well. | |
81 # https://bugzilla.mozilla.org/show_bug.cgi?id=1086553 | |
Wladimir Palant
2016/08/12 11:40:55
This comment no longer makes sense, it doesn't mat
| |
82 seamonkey_versions = get_json_versions('Seamonkey') | |
83 versions = { | 84 versions = { |
84 'current': seamonkey_versions['LATEST_SEAMONKEY_VERSION'], | 85 'current': seamonkey_versions['LATEST_SEAMONKEY_VERSION'], |
85 'unreleased': [ | 86 'unreleased': [ |
86 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'], | |
Wladimir Palant
2016/08/12 11:40:55
This should be the last entry in the list since it
| |
87 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'], | 87 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'], |
88 seamonkey_versions['LATEST_SEAMONKEY_TESTING_VERSION'], | 88 seamonkey_versions['LATEST_SEAMONKEY_TESTING_VERSION'], |
89 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'], | |
89 ] | 90 ] |
90 } | 91 } |
91 | 92 |
92 return versions | 93 return versions |
93 | 94 |
94 BROWSERS['seamonkey'] = get_seamonkey_versions | 95 BROWSERS['seamonkey'] = get_seamonkey_versions |
95 | 96 |
96 | 97 |
97 def get_chrome_version(manifest): | 98 def get_chrome_version(manifest): |
98 return manifest.getAttribute('version').split('.')[0] | 99 return manifest.getAttribute('version').split('.')[0] |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 file.seek(0) | 243 file.seek(0) |
243 json.dump(persistent_cache, file) | 244 json.dump(persistent_cache, file) |
244 file.truncate() | 245 file.truncate() |
245 | 246 |
246 if not versions['previous']: | 247 if not versions['previous']: |
247 logging.warning("Couldn't determine previous browser version, " | 248 logging.warning("Couldn't determine previous browser version, " |
248 'please set %s.previous in %s', browser, filename) | 249 'please set %s.previous in %s', browser, filename) |
249 | 250 |
250 cache[browser] = versions | 251 cache[browser] = versions |
251 return versions | 252 return versions |
LEFT | RIGHT |