Skip to content

Commit

Permalink
Check webdriver executable path before installing with pyderman (#51)
Browse files Browse the repository at this point in the history
* dev(narugo): allow this software to load chromedrive executable from env (#49)

* chore: refactor some

* fix: update deps and add types-selenium

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: narugo1992 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 31, 2023
1 parent f6df6d6 commit d25763c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 11 additions & 3 deletions gppt/_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import json
import re
import shutil
from base64 import urlsafe_b64encode
from hashlib import sha256
from random import uniform
Expand Down Expand Up @@ -57,9 +58,16 @@ def login(
self.username = username
self.password = password

executable_path = pyderman.install(verbose=False, browser=pyderman.chrome)
if type(executable_path) is not str:
raise ValueError("Executable path is not str somehow.")
executable_path = shutil.which("chromedriver")
if executable_path is None:
installed_executable_path = pyderman.install(
verbose=False, browser=pyderman.chrome
)

if not isinstance(installed_executable_path, str):
raise ValueError("Executable path is not str somehow.")

executable_path = installed_executable_path

self.driver = webdriver.Chrome(
executable_path=executable_path,
Expand Down
9 changes: 5 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ classifiers =
[options]
packages = find:
install_requires =
pixivpy3>=3.7.2
pixivpy3==3.7.2
pwinput==1.0.2
pyderman==3.3.0
requests==2.28.1
selenium==4.3.0
types-requests==2.28.1
requests==2.28.2
selenium==4.8.0
types-requests==2.28.11.8
types-selenium==3.141.9
python_requires = >=3.8
include_package_data = True

Expand Down

0 comments on commit d25763c

Please sign in to comment.