From 2c6f0f2ba37294bdb6f7f0b8462d880f0272a19d Mon Sep 17 00:00:00 2001 From: Pacman Ghost Date: Tue, 26 Sep 2023 15:56:05 +0700 Subject: [PATCH] Updated the dependencies. --- Dockerfile | 14 +++++++------- conftest.py | 10 ++++++---- docker/config/site.cfg | 1 - requirements-dev.txt | 10 +++++----- requirements.txt | 11 ++++++----- vasl_templates/webapp/scenarios.py | 2 +- .../webapp/tests/test_vasl_extensions.py | 2 +- vasl_templates/webapp/tests/utils.py | 2 +- vasl_templates/webapp/webdriver.py | 14 +++++++------- 9 files changed, 34 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index c6e2457..d7565c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,28 @@ # NOTE: Use the run-container.sh script to build and launch this container. # NOTE: Multi-stage builds require Docker >= 17.05. -FROM rockylinux:8.5 AS base +FROM rockylinux:9.1 AS base # update packages and install requirements RUN dnf -y upgrade-minimal && \ - dnf install -y python39 + dnf install -y python3.11 # NOTE: We don't need the following stuff for the build step, but it's nice to not have to re-install # it all every time we change the requirements :-/ # install Java -ARG JAVA_URL=https://download.oracle.com/java/17/archive/jdk-17.0.2_linux-x64_bin.tar.gz -RUN curl -s "$JAVA_URL" | tar -xz -C /usr/bin/ +RUN dnf install -y java-17-openjdk # install Firefox -ARG FIREFOX_URL=https://ftp.mozilla.org/pub/firefox/releases/94.0.2/linux-x86_64/en-US/firefox-94.0.2.tar.bz2 +# NOTE: We could install this using dnf, but the version of geckodriver needs to match it. +ARG FIREFOX_URL=https://ftp.mozilla.org/pub/firefox/releases/117.0.1/linux-x86_64/en-US/firefox-117.0.1.tar.bz2 RUN dnf install -y bzip2 xorg-x11-server-Xvfb gtk3 dbus-glib && \ curl -s "$FIREFOX_URL" | tar -jx -C /usr/local/ && \ ln -s /usr/local/firefox/firefox /usr/bin/firefox && \ echo "exclude=firefox" >>/etc/dnf/dnf.conf # install geckodriver -ARG GECKODRIVER_URL=https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz +ARG GECKODRIVER_URL=https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz RUN curl -sL "$GECKODRIVER_URL" | tar -xz -C /usr/bin/ # clean up @@ -33,7 +33,7 @@ RUN dnf clean all FROM base AS build # set up a virtualenv -RUN python3 -m venv /opt/venv +RUN python3.11 -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" RUN pip install --upgrade pip diff --git a/conftest.py b/conftest.py index da438cf..587ebac 100644 --- a/conftest.py +++ b/conftest.py @@ -1,6 +1,7 @@ """ pytest support functions. """ import os +import shutil import threading import json import re @@ -188,9 +189,9 @@ def _make_webapp(): # we won't have even got this far, since it needs to be there to drive the browser. # NOTE: This will have no effect if we're talking to a remote server, but we can live with that. if _pytest_options.webdriver == "firefox": - app.config[ "WEBDRIVER_PATH" ] = "geckodriver" + app.config[ "WEBDRIVER_PATH" ] = shutil.which( "geckodriver" ) elif _pytest_options.webdriver == "chrome": - app.config[ "WEBDRIVER_PATH" ] = "chromedriver" + app.config[ "WEBDRIVER_PATH" ] = shutil.which( "chromedriver" ) return app @@ -217,12 +218,13 @@ def webdriver( request ): # initialize driver = request.config.getoption( "--webdriver" ) from selenium import webdriver as wb - log_fname = os.path.join( tempfile.gettempdir(), "webdriver-pytest.log" ) if driver == "firefox": + service = wb.firefox.service.Service( + log_output = os.path.join( tempfile.gettempdir(), "webdriver-pytest.log" ) + ) options = wb.FirefoxOptions() if _pytest_options.headless: options.add_argument( "--headless" ) - service = wb.firefox.service.Service( log_path=log_fname ) driver = wb.Firefox( options=options, service=service ) elif driver == "chrome": options = wb.ChromeOptions() diff --git a/docker/config/site.cfg b/docker/config/site.cfg index 55017b2..e4259de 100644 --- a/docker/config/site.cfg +++ b/docker/config/site.cfg @@ -2,5 +2,4 @@ IS_CONTAINER = 1 -JAVA_PATH = /usr/bin/jdk-17.0.2/bin/java WEBDRIVER_PATH = /usr/bin/geckodriver diff --git a/requirements-dev.txt b/requirements-dev.txt index e4362f2..3960be2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ -pytest==7.2.2 -grpcio-tools==1.53.0 +pytest==7.4.2 +grpcio-tools==1.58.0 tabulate==0.9.0 -lxml==4.9.2 -pylint==2.17.2 +lxml==4.9.3 +pylint==2.17.5 pytest-pylint==0.19.0 -pyinstaller==5.9.0 +pyinstaller==5.13.2 diff --git a/requirements.txt b/requirements.txt index f67fedb..8e78bc3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,10 @@ -# python 3.10.10 +# python 3.11.4 -flask==2.2.3 -pyyaml==6.0 +flask==2.3.3 +pyyaml==6.0.1 +# NOTE: Pillow 9.5.0 is the last version that provides 32-bit wheels. pillow==9.5.0 -selenium==4.8.3 +selenium==4.12.0 waitress==2.1.2 appdirs==1.4.4 -click==8.1.3 +click==8.1.7 diff --git a/vasl_templates/webapp/scenarios.py b/vasl_templates/webapp/scenarios.py index ec5d943..d225a92 100644 --- a/vasl_templates/webapp/scenarios.py +++ b/vasl_templates/webapp/scenarios.py @@ -539,7 +539,7 @@ def prepare_asa_upload(): #pylint: disable=too-many-locals max_size = parse_int( app.config.get( "ASA_MAX_SCREENSHOT_SIZE" ), 200 ) * 1024 if len(screenshot_data) > max_size: ratio = math.sqrt( float(max_size) / len(screenshot_data) ) - img = img.resize( ( int(img.width * ratio), int(img.height * ratio) ), Image.ANTIALIAS ) + img = img.resize( ( int(img.width * ratio), int(img.height * ratio) ), Image.LANCZOS ) # add a border border_size = parse_int( app.config.get( "ASA_SCREENSHOT_BORDER_SIZE" ), 5 ) img = ImageOps.expand( img, border_size, (255,255,255,255) ) diff --git a/vasl_templates/webapp/tests/test_vasl_extensions.py b/vasl_templates/webapp/tests/test_vasl_extensions.py index a026ffe..6bb1d4f 100644 --- a/vasl_templates/webapp/tests/test_vasl_extensions.py +++ b/vasl_templates/webapp/tests/test_vasl_extensions.py @@ -448,7 +448,7 @@ def _check_warning_msgs( webapp, expected ): warnings = webapp.control_tests.get_vasl_mod_warnings() if expected: assert len(warnings) == 1 - if isinstance( expected, typing.re.Pattern ): + if isinstance( expected, typing.Pattern ): assert expected.search( warnings[0] ) else: assert warnings[0].startswith( expected ) diff --git a/vasl_templates/webapp/tests/utils.py b/vasl_templates/webapp/tests/utils.py index fbbfa35..ef75b0e 100644 --- a/vasl_templates/webapp/tests/utils.py +++ b/vasl_templates/webapp/tests/utils.py @@ -671,7 +671,7 @@ def wait_for_clipboard( timeout, expected, contains=None, transform=None ): if transform: clipboard = transform( clipboard ) if contains is None: - if isinstance( expected, typing.re.Pattern ): + if isinstance( expected, typing.Pattern ): return expected.search( clipboard ) is not None else: return expected == clipboard diff --git a/vasl_templates/webapp/webdriver.py b/vasl_templates/webapp/webdriver.py index 71a8b74..18b413b 100644 --- a/vasl_templates/webapp/webdriver.py +++ b/vasl_templates/webapp/webdriver.py @@ -61,7 +61,7 @@ class WebDriver: log_fname = globvars.user_profile.webdriver_log_fname if "chromedriver" in webdriver_path: options = webdriver.ChromeOptions() - options.headless = True + options.add_argument( "--headless" ) options.add_argument( "--no-sandbox" ) # nb: need this on the rPi 4 options.add_argument( "--no-proxy-server" ) # OMG! The chromedriver looks for Chrome/Chromium in a hard-coded, fixed location (the default @@ -70,23 +70,23 @@ class WebDriver: if chrome_path: options.binary_location = chrome_path service = webdriver.chrome.service.Service( - webdriver_path, log_path=log_fname + webdriver_path, log_output=log_fname ) if is_windows(): - service.creationflags = 0x8000000 # win32process.CREATE_NO_WINDOW + service.creation_flags = 0x8000000 # win32process.CREATE_NO_WINDOW self.driver = webdriver.Chrome( options=options, service=service ) elif "geckodriver" in webdriver_path: options = webdriver.FirefoxOptions() - options.headless = True + options.add_argument( "--headless" ) service = webdriver.firefox.service.Service( - webdriver_path, log_path=log_fname + webdriver_path, log_output=log_fname ) if is_windows(): - service.creationflags = 0x8000000 # win32process.CREATE_NO_WINDOW + service.creation_flags = 0x8000000 # win32process.CREATE_NO_WINDOW self.driver = webdriver.Firefox( - options=options, proxy=None, service=service + options=options, service=service ) else: raise SimpleError( "Can't identify webdriver: {}".format( webdriver_path ) )