From fb50cddc8faebf352e466ece6a2be6b7cdbe8448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 16 Jul 2024 11:51:01 +0200 Subject: [PATCH] fix: avoid exceptions on invalid capture settings --- lookyloo/capturecache.py | 4 ++-- lookyloo/helpers.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lookyloo/capturecache.py b/lookyloo/capturecache.py index 4f87ea8..2581d0d 100644 --- a/lookyloo/capturecache.py +++ b/lookyloo/capturecache.py @@ -433,8 +433,8 @@ class CapturesIndex(Mapping): # type: ignore[type-arg] with capture_settings_file.open() as f: capture_settings = json.loads(f.read()) - if capture_settings.get('url') and capture_settings['url'] is not None: - cache['url'] = capture_settings['url'] + if capture_settings.get('url') and capture_settings['url'] is not None: + cache['url'] = capture_settings['url'] if (capture_dir / 'error.txt').exists(): # Something went wrong diff --git a/lookyloo/helpers.py b/lookyloo/helpers.py index 3469112..313b837 100644 --- a/lookyloo/helpers.py +++ b/lookyloo/helpers.py @@ -29,7 +29,7 @@ from werkzeug.user_agent import UserAgent from werkzeug.utils import cached_property from .default import get_homedir, safe_create_dir, get_config, LookylooException -from .exceptions import InvalidCaptureSetting +# from .exceptions import InvalidCaptureSetting logger = logging.getLogger('Lookyloo - Helpers') @@ -139,7 +139,9 @@ def cast_capture_settings(capture_settings: dict[str, str]) -> CaptureSettings: # Value is a non-empty string, keep it as-is to_return[setting_key] = setting_value # type: ignore[literal-required] else: - raise InvalidCaptureSetting(f'Unknown setting: {setting_key} with value: {setting_value}') + # NOTE: we may have to add more settings here, will be fixed with pydantic soon. + # raise InvalidCaptureSetting(f'Unknown setting: {setting_key} with value: {setting_value}') + print(f'Unknown setting: {setting_key} with value: {setting_value}') return to_return