Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: globals/get_browser_versions.py

Issue 29348818: issue 4087 - Use Mozilla's product-details data to determine current product versions (Closed)
Patch Set: Replace update server calls with json request Created July 28, 2016, 7:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: globals/get_browser_versions.py
===================================================================
--- a/globals/get_browser_versions.py
+++ b/globals/get_browser_versions.py
@@ -25,77 +25,87 @@
<app appid="{4DC8B4CA-1BDA-483E-B5FA-D3C12E15B62D}" ap="x64-dev-multi-chrome">
<updatecheck/>
</app>
</request>'''
cache = {}
-def get_mozilla_version(product, origin_version, channel,
- minor=False, subdomain='aus4', origin_build='-',
- attribute='appVersion', platform='WINNT_x86-msvc'):
- response = urllib.urlopen('https://%s.mozilla.org/update/3/%s/%s/%s/%s/en-US/%s/-/default/default/update.xml?force=1' % (
- subdomain,
- product,
- origin_version,
- origin_build,
- platform,
- channel
- ))
+def get_firefox_version():
+ url = 'https://product-details.mozilla.org/firefox_versions.json'
+ response = urllib.urlopen(url)
try:
- doc = minidom.parse(response)
+ doc = json.loads(response.read())
Sebastian Noack 2016/08/01 16:21:07 Any reason you cannot parse the response lazily?
finally:
response.close()
-
- updates = doc.getElementsByTagName('update')
- if not updates:
- raise Exception('No updates for %s in %s channel' % (product, channel))
- full_version = updates[0].getAttribute(attribute)
-
- match = re.search(r'^(\d+)(?:\.\d+)?', full_version)
- if minor:
- return match.group(0)
- return match.group(1)
+ return doc
-def get_mozilla_versions(product, origin_version, release_minor=False):
+def get_firefox_versions():
+ versions = get_firefox_version()
return {
- 'current': get_mozilla_version(product, origin_version, 'release', release_minor),
+ 'current': versions['LATEST_FIREFOX_VERSION'],
+ 'unreleased': [
+ versions['LATEST_FIREFOX_DEVEL_VERSION'],
+ versions['FIREFOX_AURORA'],
+ versions['FIREFOX_NIGHTLY'],
+ ]
+ }
+
+
+def get_thunderbird_version():
+ url = 'https://product-details.mozilla.org/thunderbird_versions.json'
+ response = urllib.urlopen(url)
+ try:
+ doc = json.loads(response.read())
+ finally:
+ response.close()
+ return doc
+
+
+def get_thunderbird_versions():
+ versions = get_thunderbird_version()
+ firefox_versions = get_firefox_version()
+ return {
+ 'current': versions['LATEST_THUNDERBIRD_VERSION'],
'unreleased': [
- get_mozilla_version(product, origin_version, 'beta'),
- get_mozilla_version(product, origin_version, 'aurora'),
- get_mozilla_version(product, origin_version, 'nightly'),
+ versions['LATEST_THUNDERBIRD_DEVEL_VERSION'],
+ firefox_versions['FIREFOX_AURORA'],
+ firefox_versions['FIREFOX_NIGHTLY'],
]
}
-BROWSERS['firefox'] = lambda: get_mozilla_versions('Firefox', '37.0')
-BROWSERS['thunderbird'] = lambda: get_mozilla_versions('Thunderbird', '31.0', True)
+BROWSERS['firefox'] = lambda: get_firefox_versions()
+BROWSERS['thunderbird'] = lambda: get_thunderbird_versions()
-def get_seamonkey_version(origin_version, origin_build, channel, **kw):
- return get_mozilla_version('SeaMonkey', origin_version, channel, True,
- 'aus2-community', origin_build, 'version', **kw)
+def get_seamonkey_version():
Sebastian Noack 2016/08/01 16:21:07 This code duplication isn't great. How about, inst
+ url = 'http://www.seamonkey-project.org/seamonkey_versions.json'
+ response = urllib.urlopen(url)
+ try:
+ doc = json.loads(response.read())
+ finally:
+ response.close()
+ return doc
def get_seamonkey_versions():
- versions = {
- 'current': get_seamonkey_version('2.32', '20150112201917', 'release'),
- 'unreleased': [get_seamonkey_version('2.32', '20150101215737', 'beta')]
- }
-
# Aurora and Nightly builds for Windows are permantently broken.
# Occasionally, builds for other platforms are broken as well.
# https://bugzilla.mozilla.org/show_bug.cgi?id=1086553
- for channel in ('aurora', 'nightly'):
- try:
- version = get_seamonkey_version('2.32', '-', channel, platform='Linux_x86-gcc3')
- except Exception:
- continue
- versions['unreleased'].append(version)
+ seamonkey_versions = get_seamonkey_version()
+ versions = {
+ 'current': seamonkey_versions['LATEST_SEAMONKEY_VERSION'],
+ 'unreleased': [
+ seamonkey_versions['LATEST_SEAMONKEY_DEVEL_VERSION'],
+ seamonkey_versions['LATEST_SEAMONKEY_MILESTONE_VERSION'],
+ seamonkey_versions['LATEST_SEAMONKEY_TESTING_VERSION'],
+ ]
+ }
return versions
BROWSERS['seamonkey'] = get_seamonkey_versions
def get_chrome_version(manifest):
return manifest.getAttribute('version').split('.')[0]
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld