diff --git a/README.md b/README.md index 21e9adb9..0efafa12 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ We export `COLUMNS` because `se lint` needs to know the width of the terminal so Before we can use `pylint` or `mypy` on the toolset source, we have to inject them (and additional typings) into the venv `pipx` created for the `standardebooks` package: ```shell -pipx inject standardebooks pylint==3.2.2 mypy==1.10.0 types-requests==2.32.0.20240602 types-setuptools==70.0.0.20240524 types-Pillow==10.2.0.20240520 +pipx inject standardebooks pylint==3.3.3 mypy==1.14.0 types-requests==2.32.0.20241016 types-setuptools==75.6.0.20241223 types-Pillow==10.2.0.20240822 ``` Then make sure to call the `pylint` and `mypy` binaries that `pipx` installed in the `standardebooks` venv, *not* any other globally-installed binaries: diff --git a/pylintrc b/pylintrc index 6270aea0..aee75e59 100644 --- a/pylintrc +++ b/pylintrc @@ -6,7 +6,7 @@ ignore=vendor extension-pkg-whitelist=lxml,math,unicodedata [MESSAGES CONTROL] -disable=line-too-long,too-many-nested-blocks,too-many-branches,too-many-statements,too-many-boolean-expressions,too-many-lines,too-many-locals,broad-except,too-few-public-methods,too-many-arguments,too-many-instance-attributes,too-many-public-methods,duplicate-code +disable=line-too-long,too-many-nested-blocks,too-many-branches,too-many-statements,too-many-boolean-expressions,too-many-lines,too-many-locals,broad-except,too-few-public-methods,too-many-arguments,too-many-instance-attributes,too-many-public-methods,duplicate-code,too-many-positional-arguments [FORMAT] indent-string=\t diff --git a/se/browser.py b/se/browser.py index 3d17d478..80873a4d 100644 --- a/se/browser.py +++ b/se/browser.py @@ -3,16 +3,15 @@ Defines functions for interacting with headless browser sessions. """ -import os -import platform import shutil from pathlib import Path from selenium import webdriver +from selenium.webdriver.firefox.options import Options import se -def initialize_selenium_firefox_webdriver() -> webdriver.firefox.webdriver.WebDriver: +def initialize_selenium_firefox_webdriver() -> webdriver.Firefox: """ Initialize a Selenium Firefox driver and return it for use in other applications. @@ -29,8 +28,8 @@ def initialize_selenium_firefox_webdriver() -> webdriver.firefox.webdriver.WebDr # Initialize the selenium driver to take screenshots # We have to use the headless option, otherwise it will pop up a Firefox window - options = webdriver.FirefoxOptions() - options.headless = True + options = Options() + options.add_argument('-headless') # Disable the history, because otherwise links to (for example to end notes) may appear as "visited" in visits to other pages, and thus cause a fake diff profile = webdriver.FirefoxProfile() @@ -41,20 +40,6 @@ def initialize_selenium_firefox_webdriver() -> webdriver.firefox.webdriver.WebDr profile.set_preference("browser.http.use-cache", False) profile.set_preference("layout.css.devPixelsPerPx", "2.0") - possible_system_geckodriver = shutil.which("geckodriver") - - if platform.system() == "Linux": - geckodriver_path = Path("se.data.geckodriver", "geckodriver-linux64") - elif platform.system() == "Windows": - geckodriver_path = Path("se.data.geckodriver", "geckodriver-win64.exe") - elif platform.system() == "Darwin": - if platform.machine() == "arm64": - geckodriver_path = Path("se.data.geckodriver", "geckodriver-macos-aarch64") - else: - geckodriver_path = Path("se.data.geckodriver", "geckodriver-macos") - elif possible_system_geckodriver is not None: - geckodriver_path = Path(possible_system_geckodriver) - else: - raise se.MissingDependencyException("Selenium Firefox web driver is not installed. To install it on Linux or Windows, download the appropriate zip file from [url][link=https://github.com/mozilla/geckodriver/releases/latest]https://github.com/mozilla/geckodriver/releases/latest[/][/] and place the [bash]geckodriver[/] executable in your [path]$PATH[/] (for example, in [path]~/.local/bin/[/] or [path]/usr/local/bin/[/]). To install it on macOS, run [bash]brew install geckodriver[/].") - - return webdriver.Firefox(firefox_profile=profile, options=options, service_log_path=os.devnull, executable_path=geckodriver_path) + options.profile = profile + + return webdriver.Firefox(options=options) diff --git a/se/commands/compare_versions.py b/se/commands/compare_versions.py index f53d3975..0efafed9 100644 --- a/se/commands/compare_versions.py +++ b/se/commands/compare_versions.py @@ -45,11 +45,7 @@ def compare_versions(plain_output: bool) -> int: # driver.quit() if execution is interrupted (like by ctrl + c, or by an unhandled exception). If we don't call driver.quit(), # Firefox will stay around as a zombie process even if the Python script is dead. try: - try: - driver = se.browser.initialize_selenium_firefox_webdriver() - except se.MissingDependencyException as ex: - se.print_error(ex, plain_output=plain_output) - return ex.code + driver = se.browser.initialize_selenium_firefox_webdriver() # Ready to go! for target in args.targets: @@ -187,9 +183,15 @@ def compare_versions(plain_output: bool) -> int: with open(output_directory / "diff.html", "w", encoding="utf-8") as file: file.write(html) + + except se.MissingDependencyException as ex: + se.print_error(ex, plain_output=plain_output) + return ex.code + except KeyboardInterrupt as ex: # Bubble the exception up, but proceed to `finally` so we quit the driver raise ex + finally: try: driver.quit() diff --git a/se/data/geckodriver/__init__.py b/se/data/geckodriver/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/se/data/geckodriver/geckodriver-linux64 b/se/data/geckodriver/geckodriver-linux64 deleted file mode 100755 index 2cb1288d..00000000 Binary files a/se/data/geckodriver/geckodriver-linux64 and /dev/null differ diff --git a/se/data/geckodriver/geckodriver-macos b/se/data/geckodriver/geckodriver-macos deleted file mode 100755 index 68117403..00000000 Binary files a/se/data/geckodriver/geckodriver-macos and /dev/null differ diff --git a/se/data/geckodriver/geckodriver-macos-aarch64 b/se/data/geckodriver/geckodriver-macos-aarch64 deleted file mode 100755 index 1564f31c..00000000 Binary files a/se/data/geckodriver/geckodriver-macos-aarch64 and /dev/null differ diff --git a/se/data/geckodriver/geckodriver-win64.exe b/se/data/geckodriver/geckodriver-win64.exe deleted file mode 100644 index d88d78ea..00000000 Binary files a/se/data/geckodriver/geckodriver-win64.exe and /dev/null differ diff --git a/setup.py b/setup.py index df4d4777..ec1f2a6c 100644 --- a/setup.py +++ b/setup.py @@ -84,23 +84,23 @@ def _get_version() -> str: "chardet==5.2.0", "cssselect==1.2.0", "cssutils==2.9.0", - "ftfy==6.0.3", - "gitpython==3.1.41", + "ftfy==6.3.1", + "gitpython==3.1.43", "importlib_resources==1.0.2", - "lxml==4.9.3", + "lxml==5.3.0", "natsort==8.4.0", - "pillow==10.3.0", - "psutil==5.9.6", - "pyphen==0.14.0", - "regex==2023.10.3", - "requests==2.32.0", - "rich==13.7.0", - "roman==4.1", - "selenium==4.9.0", - "setuptools==70.0.0", + "pillow==11.0.0", + "psutil==6.1.1", + "pyphen==0.17.0", + "regex==2024.11.6", + "requests==2.32.3", + "rich==13.9.4", + "roman==4.2", + "selenium==4.27.1", + "setuptools==75.6.0", "smartypants==2.0.1", - "tinycss2==1.2.1", - "titlecase==2.4", - "unidecode==1.3.7" + "tinycss2==1.4.0", + "titlecase==2.4.1", + "unidecode==1.3.8" ] )