Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Various functions to install `MinGW <http://www.mingw.org/>`_.
4"""
5from __future__ import print_function
6import sys
7import os
8import re
10from .install_custom import download_page, download_file
11from ..installhelper.install_cmd_helper import unzip_files
14def install_chromedriver(dest_folder=".", fLOG=print, install=True, version=None):
15 """
16 Installs `chromedriver <https://sites.google.com/a/chromium.org/chromedriver/>`_.
18 @param dest_folder where to download the setup
19 @param fLOG logging function
20 @param install install (otherwise only download)
21 @param version version to install (unused)
22 @return zip file in a list or list of unzipped files
24 This is required for `Selenium <https://selenium-python.readthedocs.io/>`_.
25 """
26 if version is None:
27 url = "https://sites.google.com/a/chromium.org/chromedriver/"
28 content = download_page(url)
29 reg = re.compile(
30 "(<a href=\\\"https://chromedriver."
31 "storage.googleapis.com/"
32 "index.html[?]path=([0-9]+([.][0-9]+){1,3})/)")
33 f = reg.findall(content)
34 if not f:
35 raise Exception(
36 "Unable to get the last version number for ChromeDriver, "
37 "url='{}'".format(url))
38 version = f[0][1]
39 if sys.platform.startswith("win"):
40 url = "http://chromedriver.storage.googleapis.com/{0}/chromedriver_win32.zip".format(
41 version)
42 elif sys.platform.startswith("mac"):
43 url = "http://chromedriver.storage.googleapis.com/{0}/chromedriver_mac32.zip".format(
44 version)
45 else:
46 url = "http://chromedriver.storage.googleapis.com/{0}/chromedriver_linux64.zip".format(
47 version)
48 name = url.split("/")[-1]
50 outfile = os.path.join(dest_folder, name)
51 if fLOG:
52 fLOG("[pymy] chromedriver, download from ", url)
53 download_file(url, outfile, fLOG=fLOG)
55 if install:
56 return unzip_files(outfile, whereTo=dest_folder, fLOG=fLOG)
57 else:
58 return [outfile]