From d78ade600f9c37276d9d9d4b5ed834b64b9febd9 Mon Sep 17 00:00:00 2001 From: Luciano Gervasoni Date: Mon, 7 Apr 2025 12:38:30 +0200 Subject: [PATCH] MissingKids selenium app fix --- app_selenium/Dockerfile | 3 ++- app_selenium/missing_kids.py | 16 ++++------------ docker-compose-dev.yml | 7 +++++++ docker-compose.yml | 7 +++++++ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app_selenium/Dockerfile b/app_selenium/Dockerfile index 741ebe6..098f27d 100644 --- a/app_selenium/Dockerfile +++ b/app_selenium/Dockerfile @@ -1,9 +1,10 @@ FROM python:3.12 -# Architecture +# Architecture: amd64 #ARG ARCH_G=linux64 #ARG ARCH_F=linux-x86_64 +# Architecture: arm64 ARG ARCH_G=linux-aarch64 ARG ARCH_F=linux-aarch64 diff --git a/app_selenium/missing_kids.py b/app_selenium/missing_kids.py index 6774b53..0841b5f 100644 --- a/app_selenium/missing_kids.py +++ b/app_selenium/missing_kids.py @@ -8,7 +8,6 @@ import os from logger import get_logger logger = get_logger() - def get_webdriver(): options = Options() options.add_argument('--headless') # Optional @@ -62,7 +61,7 @@ class MissingKidsFetcher(): num_exceptions += 1 processed_ok = False - if (num_exceptions == 3): + if (num_exceptions == 2): continue_iterating = False else: logger.info("Exception while clicking page {}, retrying...".format(i+1)) @@ -77,22 +76,15 @@ class MissingKidsFetcher(): logger.info(e.text) # driver.refresh() - time.sleep(os.getenv("SELENIUM_SLEEP_PER_PAGE", 4)); + time.sleep(os.getenv("SELENIUM_SLEEP_PER_PAGE", 4)) if (i == first_n_pages): continue_iterating = False if (processed_ok): i += 1 num_exceptions = 0 - except Exception as e: - logger.warning("Exception while clicking page {}. {}".format(i+1, str(e)), exc_info=True) - finally: - try: - logger.info("Closing web driver and returning results") - driver.close() - except Exception as e: - logger.warning("Exception closing web driver: {}".format(str(e))) - pass + logger.warning("Exception while fetching MissingKids {}".format(str(e)), exc_info=True) + set_urls = set() return set_urls diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index a62174c..10d7f31 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -8,6 +8,13 @@ services: image: fetcher_app_selenium build: context: ./app_selenium + args: + # arm64 + #ARG ARCH_G=linux-aarch64 + #ARG ARCH_F=linux-aarch64 + # amd64 + ARG ARCH_G=linux64 + ARG ARCH_F=linux-x86_64 container_name: fetcher_app_selenium restart: unless-stopped shm_size: 512mb diff --git a/docker-compose.yml b/docker-compose.yml index 6cfcacc..6ef3f0b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,13 @@ services: image: fetcher_app_selenium build: context: ./app_selenium + args: + # arm64 + ARG ARCH_G=linux-aarch64 + ARG ARCH_F=linux-aarch64 + # amd64 + #ARG ARCH_G=linux64 + #ARG ARCH_F=linux-x86_64 container_name: fetcher_app_selenium restart: unless-stopped shm_size: 512mb