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 urllib2 | 5 import urllib2 |
6 import errno | 6 import errno |
7 import logging | 7 import logging |
8 from xml.dom import minidom | 8 from xml.dom import minidom |
9 | 9 |
10 from jinja2 import contextfunction | 10 from jinja2 import contextfunction |
11 | 11 |
12 BROWSERS = {} | 12 BROWSERS = {} |
13 | 13 |
14 CHROME_UPDATE_XML = '''\ | 14 CHROME_UPDATE_XML = '''\ |
15 <?xml version="1.0" encoding="UTF-8"?> | 15 <?xml version="1.0" encoding="UTF-8"?> |
16 <request protocol="3.0" ismachine="0"> | 16 <request protocol="3.0" ismachine="0"> |
17 <os platform="win" version="99" arch="x64"/> | 17 <os platform="win" version="99" arch="x64"/> |
18 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}"> | 18 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}"> |
19 <updatecheck/> | 19 <updatecheck/> |
20 </app> | 20 </app> |
21 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-beta-multi-chrome" > | 21 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-beta-multi-chrome" > |
22 <updatecheck/> | 22 <updatecheck/> |
23 </app> | 23 </app> |
24 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-dev-multi-chrome"> | 24 <app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-dev-multi-chrome"> |
25 <updatecheck/> | 25 <updatecheck/> |
26 </app> | 26 </app> |
27 </request>''' | 27 </request>''' |
28 | 28 |
29 def get_mozilla_version(product, origin_version, channel, minor=False, | 29 def get_mozilla_version(product, origin_version, channel, |
30 subdomain='aus4', origin_build='-', attribute='appVersio n'): | 30 minor=False, subdomain='aus4', origin_build='-', |
31 response = urllib2.urlopen('https://%s.mozilla.org/update/3/%s/%s/%s/WINNT_x86 -msvc/en-US/%s/-/default/default/update.xml?force=1' % (subdomain, product, orig in_version, origin_build, channel)) | 31 attribute='appVersion', platform='WINNT_x86-msvc'): |
32 response = urllib2.urlopen('https://%s.mozilla.org/update/3/%s/%s/%s/%s/en-US/ %s/-/default/default/update.xml?force=1' % ( | |
33 subdomain, | |
34 product, | |
35 origin_version, | |
36 origin_build, | |
37 platform, | |
38 channel | |
39 )) | |
32 try: | 40 try: |
33 doc = minidom.parse(response) | 41 doc = minidom.parse(response) |
34 finally: | 42 finally: |
35 response.close() | 43 response.close() |
36 | 44 |
37 update = doc.getElementsByTagName('update')[0] | 45 update = doc.getElementsByTagName('update')[0] |
38 full_version = update.getAttribute(attribute) | 46 full_version = update.getAttribute(attribute) |
39 | 47 |
40 match = re.search(r'^(\d+)(?:\.\d+)?', full_version) | 48 match = re.search(r'^(\d+)(?:\.\d+)?', full_version) |
41 if minor: | 49 if minor: |
42 return match.group(0) | 50 return match.group(0) |
43 return match.group(1) | 51 return match.group(1) |
44 | 52 |
45 def get_mozilla_versions(product, origin_version, release_minor=False): | 53 def get_mozilla_versions(product, origin_version, release_minor=False): |
46 return { | 54 return { |
47 'current': get_mozilla_version(product, origin_version, 'release', release_m inor), | 55 'current': get_mozilla_version(product, origin_version, 'release', release_m inor), |
48 'unreleased': [ | 56 'unreleased': [ |
49 get_mozilla_version(product, origin_version, 'beta'), | 57 get_mozilla_version(product, origin_version, 'beta'), |
50 get_mozilla_version(product, origin_version, 'aurora'), | 58 get_mozilla_version(product, origin_version, 'aurora'), |
51 get_mozilla_version(product, origin_version, 'nightly'), | 59 get_mozilla_version(product, origin_version, 'nightly'), |
52 ] | 60 ] |
53 } | 61 } |
54 | 62 |
55 BROWSERS['firefox'] = lambda: get_mozilla_versions('Firefox', '37.0') | 63 BROWSERS['firefox'] = lambda: get_mozilla_versions('Firefox', '37.0') |
Wladimir Palant
2015/05/13 13:17:23
Style nit: Please don't align columns. This might
Sebastian Noack
2015/05/13 18:35:11
Done.
| |
56 BROWSERS['thunderbird'] = lambda: get_mozilla_versions('Thunderbird', '31.0', Tr ue) | 64 BROWSERS['thunderbird'] = lambda: get_mozilla_versions('Thunderbird', '31.0', Tr ue) |
57 | 65 |
58 def get_seamonkey_version(origin_version, origin_build, channel): | 66 def get_seamonkey_version(origin_version, origin_build, channel, **kw): |
59 return get_mozilla_version('SeaMonkey', origin_version, channel, True, | 67 return get_mozilla_version('SeaMonkey', origin_version, channel, True, |
60 'aus2-community', origin_build, 'version') | 68 'aus2-community', origin_build, 'version', **kw) |
61 | 69 |
62 def get_seamonkey_versions(): | 70 def get_seamonkey_versions(): |
63 return { | 71 return { |
64 'current': get_seamonkey_version('2.32', '20150112201917', 'release'), | 72 'current': get_seamonkey_version('2.32', '20150112201917', 'release'), |
65 'unreleased': [get_seamonkey_version('2.32', '20150101215737', 'beta')] | 73 'unreleased': [ |
74 get_seamonkey_version('2.32', '20150101215737', 'beta'), | |
75 | |
76 # Aurora and Nightly builds for Windows are currently broken. | |
77 # https://bugzilla.mozilla.org/show_bug.cgi?id=1086553 | |
78 get_seamonkey_version('2.32', '-', 'aurora', platform='Linux_x86-gcc3'), | |
79 get_seamonkey_version('2.32', '-', 'nightly', platform='Linux_x86-gcc3') | |
80 ] | |
66 } | 81 } |
67 | 82 |
68 BROWSERS['seamonkey'] = get_seamonkey_versions | 83 BROWSERS['seamonkey'] = get_seamonkey_versions |
69 | 84 |
70 def get_chrome_version(manifest): | 85 def get_chrome_version(manifest): |
71 return manifest.getAttribute('version').split('.')[0] | 86 return manifest.getAttribute('version').split('.')[0] |
72 | 87 |
73 def get_chrome_versions(): | 88 def get_chrome_versions(): |
74 response = urllib2.urlopen(urllib2.Request('https://tools.google.com/service/u pdate2', CHROME_UPDATE_XML)) | 89 response = urllib2.urlopen(urllib2.Request('https://tools.google.com/service/u pdate2', CHROME_UPDATE_XML)) |
75 try: | 90 try: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 try: | 144 try: |
130 fd = os.open(filename, flags) | 145 fd = os.open(filename, flags) |
131 except OSError as e: | 146 except OSError as e: |
132 if e.errno != errno.ENOENT: | 147 if e.errno != errno.ENOENT: |
133 raise | 148 raise |
134 os.makedirs(os.path.dirname(filename)) | 149 os.makedirs(os.path.dirname(filename)) |
135 fd = os.open(filename, flags) | 150 fd = os.open(filename, flags) |
136 return os.fdopen(fd, 'w+') | 151 return os.fdopen(fd, 'w+') |
137 | 152 |
138 @contextfunction | 153 @contextfunction |
139 def get_browser_versions(context, browser): | 154 def get_browser_versions(context, browser): |
Wladimir Palant
2015/05/13 13:17:23
Just realized: Thunderbird isn't a browser :). But
Sebastian Noack
2015/05/13 18:35:11
Yeah, I already realized myself, and thought about
| |
140 func = BROWSERS[browser] | 155 func = BROWSERS[browser] |
141 exc_info = None | 156 exc_info = None |
142 try: | 157 try: |
143 versions = func() | 158 versions = func() |
144 except Exception: | 159 except Exception: |
145 exc_info = sys.exc_info() | 160 exc_info = sys.exc_info() |
146 | 161 |
147 filename = os.path.join(context['source'].get_cache_dir(), 'browsers.json') | 162 filename = os.path.join(context['source'].get_cache_dir(), 'browsers.json') |
148 with open_cache_file(filename) as file: | 163 with open_cache_file(filename) as file: |
149 try: | 164 try: |
(...skipping 18 matching lines...) Expand all Loading... | |
168 current = versions['current'] | 183 current = versions['current'] |
169 previous = None | 184 previous = None |
170 if cached_versions: | 185 if cached_versions: |
171 cached_current = cached_versions['current'] | 186 cached_current = cached_versions['current'] |
172 if cached_current != current: | 187 if cached_current != current: |
173 previous = cached_current | 188 previous = cached_current |
174 else: | 189 else: |
175 previous = cached_versions['previous'] | 190 previous = cached_versions['previous'] |
176 versions['previous'] = previous | 191 versions['previous'] = previous |
177 | 192 |
178 # Remove duplicated from unreleased versions. Occasionally, | 193 # Remove duplicates from unreleased versions. Occasionally, |
Wladimir Palant
2015/05/13 13:17:23
Typo: duplicates
Sebastian Noack
2015/05/13 18:35:11
Done.
| |
179 # different channels are on the same version, but we want | 194 # different channels are on the same version, but we want |
180 # to list each version only once. | 195 # to list each version only once. |
181 versions['unreleased'] = sorted( | 196 versions['unreleased'] = sorted( |
182 set(versions['unreleased']) - {current, previous}, | 197 set(versions['unreleased']) - {current, previous}, |
183 key=lambda ver: map(int, ver.split('.')) | 198 key=lambda ver: map(int, ver.split('.')) |
184 ) | 199 ) |
185 | 200 |
186 cache[browser] = versions | 201 cache[browser] = versions |
187 file.seek(0) | 202 file.seek(0) |
188 json.dump(cache, file) | 203 json.dump(cache, file) |
189 file.truncate() | 204 file.truncate() |
190 | 205 |
191 if not versions['previous']: | 206 if not versions['previous']: |
192 logging.warning("Couldn't determine previous browser version, " | 207 logging.warning("Couldn't determine previous browser version, " |
193 'please set %s.previous in %s', browser, filename) | 208 'please set %s.previous in %s', browser, filename) |
194 | 209 |
195 return versions | 210 return versions |
LEFT | RIGHT |