Hide keyboard shortcuts

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 

9 

10from .install_custom import download_page, download_file 

11from ..installhelper.install_cmd_helper import unzip_files 

12 

13 

14def install_operadriver(dest_folder=".", fLOG=print, install=True, version=None): 

15 """ 

16 Installs `operadriver <https://github.com/operasoftware/operachromiumdriver/releases>`_. 

17 

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 

23 

24 This is required for `Selenium <https://selenium-python.readthedocs.io/>`_. 

25 """ 

26 if version is None: 

27 content = download_page( 

28 "https://github.com/operasoftware/operachromiumdriver/releases") 

29 reg = re.compile( 

30 "/tag/v([.][0-9]+[.][0-9]+([.][0-9]+)?([.][0-9]+)?)") 

31 f = reg.findall(content) 

32 if not f: 

33 raise Exception( 

34 "unable to get the last version number for OperaDriver") 

35 version = f[0][0] 

36 if sys.platform.startswith("win"): 

37 url = "https://github.com/operasoftware/operachromiumdriver/releases/download/v{0}/operadriver_win64.zip".format( 

38 version) 

39 elif sys.platform.startswith("mac"): 

40 url = "https://github.com/operasoftware/operachromiumdriver/releases/download/v{0}/operadriver_mac64.zip".format( 

41 version) 

42 else: 

43 url = "https://github.com/operasoftware/operachromiumdriver/releases/download/v{0}/operadriver_linux64.zip".format( 

44 version) 

45 name = url.split("/")[-1] 

46 

47 outfile = os.path.join(dest_folder, name) 

48 fLOG("[pymy] operadriver, download from ", url) 

49 download_file(url, outfile, fLOG=fLOG) 

50 

51 if install: 

52 return unzip_files(outfile, whereTo=dest_folder, fLOG=fLOG) 

53 else: 

54 return [outfile]