Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
add operadriver, add setuptools as a dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Sep 9, 2016
1 parent 43aaec2 commit 532da37
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 2 deletions.
78 changes: 78 additions & 0 deletions _unittests/ut_custom_install/test_LONG_operadriver.py
@@ -0,0 +1,78 @@
"""
@brief test log(time=45s)
"""

import sys
import os
import unittest

try:
import src
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
import src

try:
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
if "PYQUICKHELPER" in os.environ and len(os.environ["PYQUICKHELPER"]) > 0:
sys.path.append(os.environ["PYQUICKHELPER"])
import pyquickhelper as skip_


from src.pymyinstall.installcustom import install_operadriver
from pyquickhelper.loghelper import fLOG

if sys.version_info[0] == 2:
FileNotFoundError = Exception


class TestOperaDriver(unittest.TestCase):

def test_install_OperaDriver(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")

if sys.version_info[0] == 2:
return

fold = os.path.abspath(os.path.split(__file__)[0])
temp = os.path.join(fold, "temp_operadriver")
if not os.path.exists(temp):
os.mkdir(temp)
for _ in os.listdir(temp):
f = os.path.join(temp, _)
if os.path.isfile(f):
os.remove(f)

r = install_operadriver(temp, fLOG=fLOG, install=True)
for _ in r:
fLOG(_)
if sys.platform.startswith("win"):
found = os.path.join(temp, "operadriver.exe")
if not os.path.exists(found):
raise FileNotFoundError(found)


if __name__ == "__main__":
unittest.main()
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -228,6 +228,6 @@ def write_version():
packages=packages,
package_dir=package_dir,
package_data=package_data,
install_requires=["pip>=7.1"],
entry_points=entry_points
install_requires=["setuptools", "pip>=7.1"],
entry_points=entry_points,
)
1 change: 1 addition & 0 deletions src/pymyinstall/installcustom/__init__.py
Expand Up @@ -14,6 +14,7 @@
from .install_custom_inkscape import install_inkscape
from .install_custom_miktex import install_miktex
from .install_custom_mingw import install_mingw
from .install_custom_operadriver import install_operadriver
from .install_custom_pandoc import install_pandoc
from .install_custom_putty import install_putty
from .install_custom_python import install_python
Expand Down
54 changes: 54 additions & 0 deletions src/pymyinstall/installcustom/install_custom_operadriver.py
@@ -0,0 +1,54 @@
"""
@file
@brief Various functions to install `MinGW <http://www.mingw.org/>`_.
"""
from __future__ import print_function
import sys
import os
import re

from .install_custom import download_page, download_file
from ..installhelper.install_cmd_helper import unzip_files


def install_operadriver(dest_folder=".", fLOG=print, install=True, version=None):
"""
install `operadriver <https://github.com/operasoftware/operachromiumdriver/releases>`_ (only on Windows)
@param dest_folder where to download the setup
@param fLOG logging function
@param install install (otherwise only download)
@param version version to install (unused)
@return zip file in a list or list of unzipped files
This is required for Selenium.
"""
if version is None:
content = download_page(
"https://github.com/operasoftware/operachromiumdriver/releases")
reg = re.compile(
"/tag/v([0-9]+[.][0-9]+[.][0-9])")
f = reg.findall(content)
if not f:
raise Exception(
"unable to get the last version number for ChromeDriver")
version = f[0]
if sys.platform.startswith("win"):
url = "https://github.com/operasoftware/operachromiumdriver/releases/download/v{0}/operadriver_win64.zip".format(
version)
elif sys.platform.startswith("mac"):
url = "https://github.com/operasoftware/operachromiumdriver/releases/download/v{0}/operadriver_mac64.zip".format(
version)
else:
url = "https://github.com/operasoftware/operachromiumdriver/releases/download/v{0}/operadriver_linux64.zip".format(
version)
name = url.split("/")[-1]

outfile = os.path.join(dest_folder, name)
fLOG("operadriver, download from ", url)
download_file(url, outfile, fLOG=fLOG)

if install:
return unzip_files(outfile, whereTo=dest_folder, fLOG=fLOG)
else:
return [outfile]

0 comments on commit 532da37

Please sign in to comment.