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

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

Issue 33003002: Updated webdriver setup script to use new location for downloads. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Whoops. Jumped the gun on deleting things. Created 7 years, 2 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 depot_tools = os.path.join('e:', depot_tools) 74 depot_tools = os.path.join('e:', depot_tools)
75 return depot_tools 75 return depot_tools
76 else: 76 else:
77 path = os.environ['PATH'].split(os.pathsep) 77 path = os.environ['PATH'].split(os.pathsep)
78 for loc in path: 78 for loc in path:
79 if 'depot_tools' in loc: 79 if 'depot_tools' in loc:
80 return loc 80 return loc
81 raise Exception("Could not find depot_tools in your path.") 81 raise Exception("Could not find depot_tools in your path.")
82 82
83 83
84 class ChromeDriverInstaller(object):
Emily Fortuna 2013/10/21 20:29:46 can this be refactored? can in it extend GoogleCod
Andrei Mouravski 2013/10/22 00:11:51 Aye, I'll do that.
85 """Install ChromeDriver from Google Storage."""
86
87 def __init__(self, download_location):
88 """ Create an object that will install ChromeDriver from Google Storage.
89 Arguments:
90 download_location - Where to download the desired file on our filesystem.
91 """
92 self.download_location = download_location
93 self.project_name = 'chromedriver'
94 self.google_storage_downloads_page = 'http://chromedriver.storage.googleapis .com'
Emily Fortuna 2013/10/21 20:29:46 80 char
95
96
97 def find_latest_version(self):
98 """Find the latest version number of ChromeDriver."""
99 f = urllib2.urlopen(self.google_storage_downloads_page)
100 latest = ''
101 l = f.read()
102 r = re.compile('(?:<Key>)(\d+\.\d+)')
103 v = max(r.findall(l))
104 return v
105
106 def run(self):
107 """Download and install the Google Code."""
108 print 'Installing from %s' % self.project_name
109 os_str = self.get_os_str
110 version = self.find_latest_version()
111 download_name = 'chromedriver_%s.zip' % os_str
112
113 urllib.urlretrieve(self.google_storage_downloads_page + '/' + version +
114 '/chromedriver_' + os_str + '.zip',
115 os.path.join(self.download_location, download_name))
116
117 if platform.system() != 'Windows':
118 # The Python zip utility does not preserve executable permissions, but
119 # this does not seem to be a problem for Windows, which does not have a
120 # built in zip utility. :-/
121 run_cmd('unzip -u %s -d %s' % (os.path.join(self.download_location,
122 download_name), self.download_location), stdin='y')
123 else:
124 z = zipfile.ZipFile(os.path.join(self.download_location, download_name))
125 z.extractall(self.download_location)
126 z.close()
127 os.remove(os.path.join(self.download_location, download_name))
128
129 chrome_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
130 'orig-chromedriver')
131 if self.project_name == 'chromedriver' and os.path.exists(chrome_path):
132 # We have one additional location to make sure chromedriver is updated.
133 # TODO(efortuna): Remove this. See move_chrome_driver_if_needed in
134 # perf_testing/run_perf_tests.py
135 driver = 'chromedriver'
136 if platform.system() == 'Windows':
137 driver += '.exe'
138 shutil.copy(os.path.join(self.download_location, driver),
139 os.path.join(chrome_path, driver))
140
141 @property
142 def get_os_str(self):
143 """The strings to indicate what OS a download is for.
144 """
145 os_str = 'win'
146 if 'darwin' in sys.platform:
147 os_str = 'mac'
148 elif 'linux' in sys.platform:
149 os_str = 'linux32'
150 if '64bit' in platform.architecture()[0]:
151 os_str = 'linux64'
152 if self.project_name == 'chromedriver' and (
153 os_str == 'mac' or os_str == 'win'):
154 os_str = os_str + '32'
155 return os_str
84 class GoogleCodeInstaller(object): 156 class GoogleCodeInstaller(object):
85 """Install code that is being hosted on Google Code.""" 157 """Install code that is being hosted on Google Code."""
86 158
87 def __init__(self, project_name, download_location, download_name_func): 159 def __init__(self, project_name, download_location, download_name_func):
88 """ Create a object that will install code from a Google Code site. 160 """ Create a object that will install code from a Google Code site.
89 Arguments: 161 Arguments:
90 project_name - The GoogleCode project name such as "selenium" or 162 project_name - The GoogleCode project name such as "selenium" or
91 "chromedriver." 163 "chromedriver."
92 download_location - Where to download the desired file on our filesystem. 164 download_location - Where to download the desired file on our filesystem.
93 download_name_func - A function that takes a dictionary (currently with keys 165 download_name_func - A function that takes a dictionary (currently with keys
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 os_str = 'mac' 458 os_str = 'mac'
387 elif 'linux' in sys.platform: 459 elif 'linux' in sys.platform:
388 os_str = 'linux' 460 os_str = 'linux'
389 return os_str 461 return os_str
390 462
391 def main(): 463 def main():
392 args = parse_args() 464 args = parse_args()
393 if not args.python: 465 if not args.python:
394 SeleniumBindingsInstaller(args.buildbot).run() 466 SeleniumBindingsInstaller(args.buildbot).run()
395 if not args.chromedriver: 467 if not args.chromedriver:
396 GoogleCodeInstaller('chromedriver', 468 ChromeDriverInstaller(find_depot_tools_location(args.buildbot)).run()
397 find_depot_tools_location(args.buildbot),
398 lambda x: 'chromedriver_%(os)s_%(version)s.zip' % x).run()
399 if not args.seleniumrc: 469 if not args.seleniumrc:
400 GoogleCodeInstaller('selenium', os.path.dirname(os.path.abspath(__file__)), 470 GoogleCodeInstaller('selenium', os.path.dirname(os.path.abspath(__file__)),
401 lambda x: 'selenium-server-standalone-%(version)s.jar' % x).run() 471 lambda x: 'selenium-server-standalone-%(version)s.jar' % x).run()
402 if not args.iedriver and platform.system() == 'Windows': 472 if not args.iedriver and platform.system() == 'Windows':
403 GoogleCodeInstaller('selenium', find_depot_tools_location(args.buildbot), 473 GoogleCodeInstaller('selenium', find_depot_tools_location(args.buildbot),
404 lambda x: 'IEDriverServer_Win32_%(version)s.zip' % x).run() 474 lambda x: 'IEDriverServer_Win32_%(version)s.zip' % x).run()
405 if not args.firefox: 475 if not args.firefox:
406 FirefoxInstaller().run() 476 FirefoxInstaller().run()
407 if not args.opera: 477 if not args.opera:
408 OperaInstaller().run() 478 OperaInstaller().run()
409 479
410 if __name__ == '__main__': 480 if __name__ == '__main__':
411 main() 481 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