Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: tools/testing/webdriver_test_setup.py

Issue 23334005: Update webdriver setup script for Download name changes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« 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 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 # Run to install the necessary components to run webdriver on the buildbots or 7 # Run to install the necessary components to run webdriver on the buildbots or
8 # on your local machine. 8 # on your local machine.
9 # Note: The setup steps can be done fairly easily by hand. This script is 9 # Note: The setup steps can be done fairly easily by hand. This script is
10 # intended to simply and reduce the time for setup since there are a fair number 10 # intended to simply and reduce the time for setup since there are a fair number
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 latest = '' 117 latest = ''
118 for line in f.readlines(): 118 for line in f.readlines():
119 if re.search(self.download_regex_str, line): 119 if re.search(self.download_regex_str, line):
120 suffix_index = line.find( 120 suffix_index = line.find(
121 self.download_regex_str[self.download_regex_str.rfind('.'):]) 121 self.download_regex_str[self.download_regex_str.rfind('.'):])
122 name_end = self.download_regex_str.rfind('.+') 122 name_end = self.download_regex_str.rfind('.+')
123 name = self.download_name_func({'os': self.get_os_str, 'version': ''}) 123 name = self.download_name_func({'os': self.get_os_str, 'version': ''})
124 name = name[:name.rfind('.')] 124 name = name[:name.rfind('.')]
125 version_str = line[line.find(name) + len(name) : suffix_index] 125 version_str = line[line.find(name) + len(name) : suffix_index]
126 orig_version_str = version_str 126 orig_version_str = version_str
127 » if version_str.count('.') == 0: 127 if version_str.count('.') == 0:
128 version_str = version_str.replace('_', '.') 128 version_str = version_str.replace('_', '.')
129 » version_str = re.compile(r'[^\d.]+').sub('', version_str) 129 version_str = re.compile(r'[^\d.]+').sub('', version_str)
130 if latest == '': 130 if latest == '':
131 latest = '0.' * version_str.count('.') 131 latest = '0.' * version_str.count('.')
132 latest += '0' 132 latest += '0'
133 » orig_latest_str = latest 133 orig_latest_str = latest
134 » else: 134 else:
135 » orig_latest_str = latest 135 orig_latest_str = latest
136 latest = latest.replace('_', '.') 136 latest = latest.replace('_', '.')
137 latest = re.compile(r'[^\d.]+').sub('', latest) 137 latest = re.compile(r'[^\d.]+').sub('', latest)
138 nums = version_str.split('.') 138 nums = version_str.split('.')
139 latest_nums = latest.split('.') 139 latest_nums = latest.split('.')
140 for (num, latest_num) in zip(nums, latest_nums): 140 for (num, latest_num) in zip(nums, latest_nums):
141 if int(num) > int(latest_num): 141 if int(num) > int(latest_num):
142 latest = orig_version_str 142 latest = orig_version_str
143 break 143 break
144 else: 144 else:
145 latest = orig_latest_str 145 latest = orig_latest_str
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 def get_os_str(self): 184 def get_os_str(self):
185 """The strings to indicate what OS a download is for as used on Google Code. 185 """The strings to indicate what OS a download is for as used on Google Code.
186 """ 186 """
187 os_str = 'win' 187 os_str = 'win'
188 if 'darwin' in sys.platform: 188 if 'darwin' in sys.platform:
189 os_str = 'mac' 189 os_str = 'mac'
190 elif 'linux' in sys.platform: 190 elif 'linux' in sys.platform:
191 os_str = 'linux32' 191 os_str = 'linux32'
192 if '64bit' in platform.architecture()[0]: 192 if '64bit' in platform.architecture()[0]:
193 os_str = 'linux64' 193 os_str = 'linux64'
194 if self.project_name == 'chromedriver' and (
195 os_str == 'mac' or os_str == 'win'):
196 os_str = os_str + '32'
194 return os_str 197 return os_str
195 198
196 199
197 class FirefoxInstaller(object): 200 class FirefoxInstaller(object):
198 """Installs the latest version of Firefox on the machine.""" 201 """Installs the latest version of Firefox on the machine."""
199 202
200 def ff_download_site(self, os_name): 203 def ff_download_site(self, os_name):
201 return 'http://releases.mozilla.org/pub/mozilla.org/firefox/releases/' + \ 204 return 'http://releases.mozilla.org/pub/mozilla.org/firefox/releases/' + \
202 'latest/%s/en-US/' % os_name 205 'latest/%s/en-US/' % os_name
203 206
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 246
244 247
245 class SeleniumBindingsInstaller(object): 248 class SeleniumBindingsInstaller(object):
246 """Install the Selenium Webdriver bindings for Python.""" 249 """Install the Selenium Webdriver bindings for Python."""
247 250
248 SETUPTOOLS_SITE = 'http://python-distribute.org/distribute_setup.py' 251 SETUPTOOLS_SITE = 'http://python-distribute.org/distribute_setup.py'
249 PIP_SITE = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py' 252 PIP_SITE = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py'
250 def __init__(self, is_buildbot): 253 def __init__(self, is_buildbot):
251 self.is_buildbot = is_buildbot 254 self.is_buildbot = is_buildbot
252 255
253 def run(self): 256 def run(self):
254 print 'Installing Selenium Python Bindings' 257 print 'Installing Selenium Python Bindings'
255 admin_keyword = '' 258 admin_keyword = ''
256 python_cmd = 'python' 259 python_cmd = 'python'
257 pip_cmd = 'pip' 260 pip_cmd = 'pip'
258 if 'win32' not in sys.platform and 'cygwin' not in sys.platform: 261 if 'win32' not in sys.platform and 'cygwin' not in sys.platform:
259 admin_keyword = 'sudo' 262 admin_keyword = 'sudo'
260 pip_cmd = '/usr/local/bin/pip' 263 pip_cmd = '/usr/local/bin/pip'
261 else: 264 else:
262 # The python installation is "special" on Windows buildbots. 265 # The python installation is "special" on Windows buildbots.
263 if self.is_buildbot: 266 if self.is_buildbot:
(...skipping 15 matching lines...) Expand all
279 282
280 class OperaHtmlParser(HTMLParser.HTMLParser): 283 class OperaHtmlParser(HTMLParser.HTMLParser):
281 """A helper class to parse Opera pages listing available downloads to find the 284 """A helper class to parse Opera pages listing available downloads to find the
282 correct download we want.""" 285 correct download we want."""
283 286
284 def initialize(self, rejection_func, accept_func): 287 def initialize(self, rejection_func, accept_func):
285 """Initialize some state for our parser. 288 """Initialize some state for our parser.
286 Arguments: 289 Arguments:
287 rejection_func: A function that accepts the value of the URL and determines 290 rejection_func: A function that accepts the value of the URL and determines
288 if it is of the type we are looking for. 291 if it is of the type we are looking for.
289 accept_func: A function that takes the URL and the "current best" URL and 292 accept_func: A function that takes the URL and the "current best" URL and
290 determines if it is better than our current download url.""" 293 determines if it is better than our current download url."""
291 self.latest = 0 294 self.latest = 0
292 self.rejection_func = rejection_func 295 self.rejection_func = rejection_func
293 self.accept_func = accept_func 296 self.accept_func = accept_func
294 297
295 def handle_starttag(self, tag, attrs): 298 def handle_starttag(self, tag, attrs):
296 """Find the latest version.""" 299 """Find the latest version."""
297 if (tag == 'a' and attrs[0][0] == 'href' and 300 if (tag == 'a' and attrs[0][0] == 'href' and
298 self.rejection_func(attrs[0][1])): 301 self.rejection_func(attrs[0][1])):
299 self.latest = self.accept_func(attrs[0][1], self.latest) 302 self.latest = self.accept_func(attrs[0][1], self.latest)
300 303
301 class OperaInstaller(object): 304 class OperaInstaller(object):
302 """Install from the Opera FTP website.""" 305 """Install from the Opera FTP website."""
303 306
304 def find_latest_version(self, download_page, rejection_func, accept_func): 307 def find_latest_version(self, download_page, rejection_func, accept_func):
305 """Get the latest non-beta version. 308 """Get the latest non-beta version.
306 Arguments: 309 Arguments:
307 download_page: The initial page that lists all the download options. 310 download_page: The initial page that lists all the download options.
308 rejection_func: A function that accepts the value of the URL and determines 311 rejection_func: A function that accepts the value of the URL and determines
309 if it is of the type we are looking for. 312 if it is of the type we are looking for.
310 accept_func: A function that takes the URL and the "current best" URL and 313 accept_func: A function that takes the URL and the "current best" URL and
311 determines if it is better than our current download url.""" 314 determines if it is better than our current download url."""
312 f = urllib2.urlopen(download_page) 315 f = urllib2.urlopen(download_page)
313 parser = OperaHtmlParser() 316 parser = OperaHtmlParser()
314 parser.initialize(rejection_func, accept_func) 317 parser.initialize(rejection_func, accept_func)
315 parser.feed(f.read()) 318 parser.feed(f.read())
316 return str(parser.latest) 319 return str(parser.latest)
317 320
318 def run(self): 321 def run(self):
319 """Download and install Opera.""" 322 """Download and install Opera."""
320 print 'Installing Opera' 323 print 'Installing Opera'
321 os_str = self.get_os_str 324 os_str = self.get_os_str
322 download_name = 'http://ftp.opera.com/pub/opera/%s/' % os_str 325 download_name = 'http://ftp.opera.com/pub/opera/%s/' % os_str
323 326
324 def higher_revision(new_version_str, current): 327 def higher_revision(new_version_str, current):
325 version_string = new_version_str[:-1] 328 version_string = new_version_str[:-1]
326 if int(version_string) > current: 329 if int(version_string) > current:
327 return int(version_string) 330 return int(version_string)
328 return current 331 return current
329 332
330 version = self.find_latest_version( 333 version = self.find_latest_version(
331 download_name, 334 download_name,
332 lambda x: x[0] in string.digits and 'b' not in x and 'rc' not in x, 335 lambda x: x[0] in string.digits and 'b' not in x and 'rc' not in x,
333 higher_revision) 336 higher_revision)
334 download_name += version 337 download_name += version
335 if ('linux' in sys.platform and 338 if ('linux' in sys.platform and
336 platform.linux_distribution()[0] == 'Ubuntu'): 339 platform.linux_distribution()[0] == 'Ubuntu'):
337 # Last time I tried, the .deb file you download directly from opera was 340 # Last time I tried, the .deb file you download directly from opera was
338 # not installing correctly on Ubuntu. This installs Opera more nicely. 341 # not installing correctly on Ubuntu. This installs Opera more nicely.
339 os.system("sudo sh -c 'wget -O - http://deb.opera.com/archive.key | " 342 os.system("sudo sh -c 'wget -O - http://deb.opera.com/archive.key | "
340 "apt-key add -'") 343 "apt-key add -'")
341 os.system("""sudo sh -c 'echo "deb http://deb.opera.com/opera/ """ 344 os.system("""sudo sh -c 'echo "deb http://deb.opera.com/opera/ """
342 """stable non-free" > /etc/apt/sources.list.d/opera.list'""") 345 """stable non-free" > /etc/apt/sources.list.d/opera.list'""")
343 run_cmd('sudo apt-get update') 346 run_cmd('sudo apt-get update')
344 run_cmd('sudo apt-get install opera', stdin='y') 347 run_cmd('sudo apt-get install opera', stdin='y')
345 else: 348 else:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if not args.iedriver and platform.system() == 'Windows': 402 if not args.iedriver and platform.system() == 'Windows':
400 GoogleCodeInstaller('selenium', find_depot_tools_location(args.buildbot), 403 GoogleCodeInstaller('selenium', find_depot_tools_location(args.buildbot),
401 lambda x: 'IEDriverServer_Win32_%(version)s.zip' % x).run() 404 lambda x: 'IEDriverServer_Win32_%(version)s.zip' % x).run()
402 if not args.firefox: 405 if not args.firefox:
403 FirefoxInstaller().run() 406 FirefoxInstaller().run()
404 if not args.opera: 407 if not args.opera:
405 OperaInstaller().run() 408 OperaInstaller().run()
406 409
407 if __name__ == '__main__': 410 if __name__ == '__main__':
408 main() 411 main()
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 408576698