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': | |
36 'https://product-details.mozilla.org/1.0/firefox_versions.json', | |
37 'Thunderbird': | |
38 'https://product-details.mozilla.org/1.0/thunderbird_versions.json', | |
39 'Seamonkey': | |
40 'http://www.seamonkey-project.org/seamonkey_versions.json' | |
41 } | |
42 response = urllib.urlopen(urls[product]) | |
43 try: | 39 try: |
44 doc = json.load(response) | 40 doc = json.load(response) |
45 finally: | 41 except json.ValueError: |
46 response.close() | 42 print 'URL: %s not returning json object'.format(product_url) |
| 43 finally: |
| 44 response.close() |
| 45 |
47 for key, value in doc.iteritems(): | 46 for key, value in doc.iteritems(): |
48 doc[key] = re.split(r'([a-zA-z])', value)[0] | 47 if value: |
| 48 match = re.search(r'^(\d+)(?:\.\d+)?', value) |
| 49 if match: |
| 50 doc[key] = match.group(0) |
49 return doc | 51 return doc |
50 | 52 |
51 | 53 |
52 def get_firefox_versions(): | 54 def get_firefox_versions(): |
53 versions = get_json_versions('Firefox') | 55 versions = get_json_versions(FIREFOX_URL) |
54 return { | 56 return { |
55 'current': versions['LATEST_FIREFOX_VERSION'], | 57 'current': versions['LATEST_FIREFOX_VERSION'], |
56 'unreleased': [ | 58 'unreleased': [ |
57 versions['LATEST_FIREFOX_DEVEL_VERSION'], | 59 versions['LATEST_FIREFOX_DEVEL_VERSION'], |
58 versions['FIREFOX_AURORA'], | 60 versions['FIREFOX_AURORA'], |
59 versions['FIREFOX_NIGHTLY'], | 61 versions['FIREFOX_NIGHTLY'], |
60 ] | 62 ] |
61 } | 63 } |
62 | 64 |
63 | 65 |
64 def get_thunderbird_versions(): | 66 def get_thunderbird_versions(): |
65 versions = get_json_versions('Thunderbird') | 67 tbird_versions = get_json_versions(THUNDERBIRD_URL) |
66 firefox_versions = get_json_versions('Firefox') | 68 firefox_versions = get_json_versions(FIREFOX_URL) |
67 return { | 69 return { |
68 'current': versions['LATEST_THUNDERBIRD_VERSION'], | 70 'current': tbird_versions['LATEST_THUNDERBIRD_VERSION'], |
69 'unreleased': [ | 71 'unreleased': [ |
70 versions['LATEST_THUNDERBIRD_DEVEL_VERSION'], | 72 tbird_versions['LATEST_THUNDERBIRD_DEVEL_VERSION'], |
71 versions['LATEST_THUNDERBIRD_ALPHA'], | 73 tbird_versions['LATEST_THUNDERBIRD_ALPHA_VERSION'], |
72 firefox_versions['FIREFOX_NIGHTLY'], | 74 firefox_versions['FIREFOX_NIGHTLY'], |
73 ] | 75 ] |
74 } | 76 } |
75 | 77 |
76 BROWSERS['firefox'] = lambda: get_firefox_versions() | 78 BROWSERS['firefox'] = lambda: get_firefox_versions() |
77 BROWSERS['thunderbird'] = lambda: get_thunderbird_versions() | 79 BROWSERS['thunderbird'] = lambda: get_thunderbird_versions() |
78 | 80 |
79 | 81 |
80 def get_seamonkey_versions(): | 82 def get_seamonkey_versions(): |
81 seamonkey_versions = get_json_versions('Seamonkey') | 83 seamonkey_versions = get_json_versions(SEAMONKEY_URL) |
82 versions = { | 84 versions = { |
83 'current': seamonkey_versions['LATEST_SEAMONKEY_VERSION'], | 85 'current': seamonkey_versions['LATEST_SEAMONKEY_VERSION'], |
84 'unreleased': [ | 86 'unreleased': [ |
85 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'], | 87 seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'], |
86 seamonkey_versions['LATEST_SEAMONKEY_TESTING_VERSION'], | 88 seamonkey_versions['LATEST_SEAMONKEY_TESTING_VERSION'], |
87 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'], | 89 seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'], |
88 ] | 90 ] |
89 } | 91 } |
90 | 92 |
91 return versions | 93 return versions |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 file.seek(0) | 243 file.seek(0) |
242 json.dump(persistent_cache, file) | 244 json.dump(persistent_cache, file) |
243 file.truncate() | 245 file.truncate() |
244 | 246 |
245 if not versions['previous']: | 247 if not versions['previous']: |
246 logging.warning("Couldn't determine previous browser version, " | 248 logging.warning("Couldn't determine previous browser version, " |
247 'please set %s.previous in %s', browser, filename) | 249 'please set %s.previous in %s', browser, filename) |
248 | 250 |
249 cache[browser] = versions | 251 cache[browser] = versions |
250 return versions | 252 return versions |
LEFT | RIGHT |