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

Side by Side Diff: globals/get_browser_versions.py

Issue 5341722020151296: Issue 2628 - Fix stable version of Yandex.Browser listed on the requirements page (Closed)
Patch Set: Created June 3, 2015, 4:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return { 121 return {
122 'current': get_opera_version('Stable'), 122 'current': get_opera_version('Stable'),
123 'unreleased': [ 123 'unreleased': [
124 get_opera_version('Beta'), 124 get_opera_version('Beta'),
125 get_opera_version('Developer') 125 get_opera_version('Developer')
126 ] 126 ]
127 } 127 }
128 128
129 BROWSERS['opera'] = get_opera_versions 129 BROWSERS['opera'] = get_opera_versions
130 130
131 def get_yandex_version(suffix): 131 def get_yandex_version(beta=False):
132 response = urllib.urlopen('https://api.browser.yandex.ru/update-info/browser/y andex%s/win-yandex.xml' % suffix) 132 url = 'https://api.browser.yandex.ru/update-info/browser/yandex%s/win-yandex.x ml%s'
133 if beta:
134 url %= ('-beta', '')
135 else:
136 url %= ('', '?manual=yes')
137
138 response = urllib.urlopen(url)
133 try: 139 try:
134 doc = minidom.parse(response) 140 doc = minidom.parse(response)
135 finally: 141 finally:
136 response.close() 142 response.close()
137 143
138 item = doc.getElementsByTagName('item')[0] 144 item = doc.getElementsByTagName('item')[0]
139 description = item.getElementsByTagName('description')[0] 145 description = item.getElementsByTagName('description')[0]
140 return re.search(r'\d+\.\d+', description.firstChild.nodeValue).group(0) 146 return re.search(r'\d+\.\d+', description.firstChild.nodeValue).group(0)
141 147
142 def get_yandex_versions(): 148 def get_yandex_versions():
143 return { 149 return {
144 'current': get_yandex_version(''), 150 'current': get_yandex_version(),
145 'unreleased': [get_yandex_version('-beta')] 151 'unreleased': [get_yandex_version(beta=True)]
146 } 152 }
147 153
148 BROWSERS['yandex'] = get_yandex_versions 154 BROWSERS['yandex'] = get_yandex_versions
149 155
150 def open_cache_file(filename): 156 def open_cache_file(filename):
151 flags = os.O_RDWR | os.O_CREAT 157 flags = os.O_RDWR | os.O_CREAT
152 try: 158 try:
153 fd = os.open(filename, flags) 159 fd = os.open(filename, flags)
154 except OSError as e: 160 except OSError as e:
155 if e.errno != errno.ENOENT: 161 if e.errno != errno.ENOENT:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 file.seek(0) 223 file.seek(0)
218 json.dump(persistent_cache, file) 224 json.dump(persistent_cache, file)
219 file.truncate() 225 file.truncate()
220 226
221 if not versions['previous']: 227 if not versions['previous']:
222 logging.warning("Couldn't determine previous browser version, " 228 logging.warning("Couldn't determine previous browser version, "
223 'please set %s.previous in %s', browser, filename) 229 'please set %s.previous in %s', browser, filename)
224 230
225 cache[browser] = versions 231 cache[browser] = versions
226 return versions 232 return versions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld