Changeset 219853 in webkit
- Timestamp:
- Jul 24, 2017 6:42:03 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r219850 r219853 1 2017-07-24 Matthew Stewart <matthew_r_stewart@apple.com> 2 3 Add functions to autoinstaller needed for Benchmark Runner script 4 https://bugs.webkit.org/show_bug.cgi?id=174331 5 6 Reviewed by Dean Johnson, Dewei Zhu, Stephanie Lewis. 7 8 Adds autoinstaller functions to install selenium and webdriver binaries 9 which will be used by the browser driver part of Benchmark Runner. 10 11 * Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py: 12 (BrowserDriver.restore_env): 13 (BrowserDriver): 14 (BrowserDriver.get_webdriver_binary_path): 15 * Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py: 16 (LinuxChromeDriver.launch_driver): 17 * Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py: 18 (LinuxFirefoxDriver.launch_driver): 19 * Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py: 20 (OSXChromeDriver.launch_driver): 21 (OSXChromeCanaryDriver.launch_driver): 22 * Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py: 23 (OSXFirefoxDriver.launch_driver): 24 (OSXFirefoxNightlyDriver.launch_driver): 25 * Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py: 26 * Scripts/webkitpy/benchmark_runner/utils.py: 27 (get_driver_binary_path): 28 * Scripts/webkitpy/common/system/autoinstall.py: 29 (AutoInstaller._unzip): 30 * Scripts/webkitpy/thirdparty/__init__.py: 31 (AutoinstallImportHook.find_module): 32 (AutoinstallImportHook._install_selenium): 33 (AutoinstallImportHook): 34 (AutoinstallImportHook._install_chromedriver): 35 (AutoinstallImportHook._install_geckodriver): 36 (AutoinstallImportHook.get_latest_pypi_url): 37 (AutoinstallImportHook.install_binary): 38 (autoinstall_everything): 39 (get_driver_filename): 40 (get_os_info): 41 1 42 2017-07-24 Matthew Stewart <matthew_r_stewart@apple.com> 2 43 -
trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py
r219850 r219853 2 2 3 3 from abc import ABCMeta, abstractmethod 4 from webkitpy.benchmark_runner.utils import get_driver_binary_path 4 5 5 6 … … 33 34 def restore_env(self): 34 35 pass 36 37 @property 38 def webdriver_binary_path(self): 39 return get_driver_binary_path(self.browser_name) -
trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py
r219850 r219853 50 50 binary_path = os.path.join(browser_build_path, 'chromium-browser') 51 51 options.binary_location = binary_path 52 driver = webdriver.Chrome(chrome_options=options) 52 driver_executable = self.webdriver_binary_path 53 driver = webdriver.Chrome(chrome_options=options, executable_path=driver_executable) 53 54 super(LinuxChromeDriver, self).launch_webdriver(url, driver) 54 55 return driver -
trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py
r219850 r219853 48 48 binary_path = os.path.join(browser_build_path, 'firefox-bin') 49 49 options.binary_location = binary_path 50 driver = webdriver.Firefox(firefox_options=options) 50 driver_executable = self.webdriver_binary_path 51 driver = webdriver.Firefox(firefox_options=options, executable_path=driver_executable) 51 52 super(LinuxFirefoxDriver, self).launch_webdriver(url, driver) 52 53 return driver -
trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py
r219850 r219853 3 3 import logging 4 4 import os 5 import subprocess6 import time7 5 8 6 from osx_browser_driver import OSXBrowserDriver … … 35 33 binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name) 36 34 chrome_options.binary_location = binary_path 37 driver = webdriver.Chrome(chrome_options=chrome_options) 35 driver_executable = self.webdriver_binary_path 36 driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable) 38 37 self._launch_webdriver(url=url, driver=driver) 39 38 return driver … … 55 54 binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name) 56 55 chrome_options.binary_location = binary_path 57 driver = webdriver.Chrome(chrome_options=chrome_options) 56 driver_executable = self.webdriver_binary_path 57 driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable) 58 58 self._launch_webdriver(url=url, driver=driver) 59 59 return driver -
trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py
r219850 r219853 3 3 import logging 4 4 import os 5 import subprocess6 import time7 5 8 6 from osx_browser_driver import OSXBrowserDriver … … 31 29 binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name) 32 30 firefox_options.binary_location = binary_path 33 driver = webdriver.Firefox(firefox_options=firefox_options) 31 driver_executable = self.webdriver_binary_path 32 driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable) 34 33 self._launch_webdriver(url=url, driver=driver) 35 34 return driver … … 51 50 binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name) 52 51 firefox_options.binary_location = binary_path 53 driver = webdriver.Firefox(firefox_options=firefox_options) 52 driver_executable = self.webdriver_binary_path 53 driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable) 54 54 self._launch_webdriver(url=url, driver=driver) 55 55 return driver -
trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py
r219850 r219853 3 3 import logging 4 4 import os 5 import re6 5 import subprocess 7 6 import time -
trunk/Tools/Scripts/webkitpy/benchmark_runner/utils.py
r209090 r219853 8 8 import shutil 9 9 import sys 10 11 from webkitpy.common.memoized import memoized 10 12 11 13 … … 45 47 _log.info("Error removing %s: %s" % (path, error)) 46 48 pass 49 50 51 @memoized 52 def get_driver_binary_path(browser_name): 53 if browser_name.startswith('chrome'): 54 import webkitpy.thirdparty.autoinstalled.chromedriver 55 driver_init_file = webkitpy.thirdparty.autoinstalled.chromedriver.__file__ 56 driver_executable = os.path.join(os.path.dirname(os.path.realpath(driver_init_file)), 'chromedriver') 57 return driver_executable 58 elif browser_name.startswith('firefox'): 59 import webkitpy.thirdparty.autoinstalled.geckodriver 60 driver_init_file = webkitpy.thirdparty.autoinstalled.geckodriver.__file__ 61 driver_executable = os.path.join(os.path.dirname(os.path.realpath(driver_init_file)), 'geckodriver') 62 return driver_executable 47 63 48 64 -
trunk/Tools/Scripts/webkitpy/common/system/autoinstall.py
r212852 r219853 276 276 277 277 try: 278 self._extract_all(zip_file, scratch_dir)278 self._extract_all(zip_file, target_path) 279 279 finally: 280 280 zip_file.close() -
trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py
r209216 r219853 27 27 28 28 import codecs 29 import json 29 30 import os 31 import re 30 32 import sys 31 33 import urllib2 34 35 from collections import namedtuple 36 from distutils import spawn 32 37 from webkitpy.common.system.autoinstall import AutoInstaller 33 38 from webkitpy.common.system.filesystem import FileSystem … … 35 40 _THIRDPARTY_DIR = os.path.dirname(__file__) 36 41 _AUTOINSTALLED_DIR = os.path.join(_THIRDPARTY_DIR, "autoinstalled") 42 43 CHROME_DRIVER_URL = "http://chromedriver.storage.googleapis.com/" 44 FIREFOX_RELEASES_URL = "https://api.github.com/repos/mozilla/geckodriver/releases" 37 45 38 46 # Putting the autoinstall code into webkitpy/thirdparty/__init__.py … … 47 55 # 48 56 # webkitpy/thirdparty/autoinstalled 57 49 58 fs = FileSystem() 50 59 fs.maybe_make_directory(_AUTOINSTALLED_DIR) … … 92 101 elif '.twisted_15_5_0' in fullname: 93 102 self._install_twisted_15_5_0() 103 elif '.selenium' in fullname: 104 self._install_selenium() 105 elif '.chromedriver' in fullname: 106 self._install_chromedriver() 107 elif '.geckodriver' in fullname: 108 self._install_geckodriver() 94 109 95 110 def _install_mechanize(self): … … 152 167 installer.install(url="https://pypi.python.org/packages/source/z/zope.interface/zope.interface-4.1.3.tar.gz#md5=9ae3d24c0c7415deb249dd1a132f0f79", url_subpath="zope.interface-4.1.3/src/zope") 153 168 169 def _install_selenium(self): 170 self._ensure_autoinstalled_dir_is_in_sys_path() 171 url, url_subpath = self.get_latest_pypi_url('selenium') 172 self._install(url=url, url_subpath=url_subpath) 173 174 def _install_chromedriver(self): 175 filename_postfix = get_driver_filename().chrome 176 if filename_postfix != "unsupported": 177 version = urllib2.urlopen(CHROME_DRIVER_URL + 'LATEST_RELEASE').read().strip() 178 full_chrome_url = "{base_url}{version}/chromedriver_{os}.zip".format(base_url=CHROME_DRIVER_URL, version=version, os=filename_postfix) 179 self.install_binary(full_chrome_url, 'chromedriver') 180 181 def _install_geckodriver(self): 182 filename_postfix = get_driver_filename().firefox 183 if filename_postfix != "unsupported": 184 firefox_releases_blob = urllib2.urlopen(FIREFOX_RELEASES_URL) 185 firefox_releases_line_separated = json.dumps(json.load(firefox_releases_blob), indent=0).strip() 186 all_firefox_release_urls = "\n".join(re.findall(r'.*browser_download_url.*', firefox_releases_line_separated)) 187 full_firefox_url = re.findall(r'.*%s.*' % filename_postfix, all_firefox_release_urls)[0].split('"')[3] 188 self.install_binary(full_firefox_url, 'geckodriver') 189 154 190 def _install(self, url, url_subpath=None, target_name=None): 155 191 installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR) 156 192 installer.install(url=url, url_subpath=url_subpath, target_name=target_name) 193 194 def get_latest_pypi_url(self, package_name, url_subpath_format='{name}-{version}/{lname}'): 195 json_url = "https://pypi.python.org/pypi/%s/json" % package_name 196 response = urllib2.urlopen(json_url) 197 data = json.load(response) 198 url = data['urls'][1]['url'] 199 subpath = url_subpath_format.format(name=package_name, version=data['info']['version'], lname=package_name.lower()) 200 return (url, subpath) 201 202 def install_binary(self, url, name): 203 self._install(url=url, target_name=name) 204 directory = os.path.join(_AUTOINSTALLED_DIR, name) 205 os.chmod(os.path.join(directory, name), 0755) 206 open(os.path.join(directory, '__init__.py'), 'w+').close() 157 207 158 208 … … 165 215 for method in install_methods: 166 216 getattr(_hook, method)() 217 218 def get_driver_filename(): 219 os_name, os_type = get_os_info() 220 chrome_os, filefox_os = 'unsupported', 'unsupported' 221 if os_name == 'Linux' and os_type == '64': 222 chrome_os, firefox_os = 'linux64', 'linux64' 223 elif os_name == 'Linux': 224 chrome_os, firefox_os = 'linux32', 'linux32' 225 elif os_name == 'Darwin': 226 chrome_os, firefox_os = 'mac64', 'macos' 227 DriverFilenameForBrowser = namedtuple('DriverFilenameForBrowser', ['chrome', 'firefox']) 228 return DriverFilenameForBrowser(chrome_os, firefox_os) 229 230 def get_os_info(): 231 import platform 232 os_name = platform.system() 233 os_type = platform.machine()[-2:] 234 return (os_name, os_type)
Note: See TracChangeset
for help on using the changeset viewer.