From c36030856dd73a602f5fc9254d7cccde16867d29 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 14 Jun 2023 08:58:12 +0200 Subject: [PATCH] fix: get screenshot dir using config file --- ofx_processor/downloaders/lcl.py | 2 +- ofx_processor/utils/config.py | 4 ++++ pyproject.toml | 2 +- tests/samples/config.ini | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ofx_processor/downloaders/lcl.py b/ofx_processor/downloaders/lcl.py index 0222c40..b03c47f 100644 --- a/ofx_processor/downloaders/lcl.py +++ b/ofx_processor/downloaders/lcl.py @@ -39,7 +39,7 @@ class LclDownloader: try: return self._download() except Exception: - screenshot = Path(os.getenv("SCREENSHOT_DIR", default="/tmp")) / "error_download.png" + screenshot = Path(self.config.screenshot_dir) / "error_download_lcl.png" self.selenium.save_screenshot(screenshot) raise diff --git a/ofx_processor/utils/config.py b/ofx_processor/utils/config.py index 9c43cad..ac941a7 100644 --- a/ofx_processor/utils/config.py +++ b/ofx_processor/utils/config.py @@ -17,6 +17,7 @@ def get_default_config(): default_config["DEFAULT"] = { "token": "", "budget": "", + "screenshot_dir": "/tmp", "mailgun_api_key": "", "mailgun_domain": "", "mailgun_from": "", @@ -76,6 +77,7 @@ class Config: account: str budget_id: str token: str + screenshot_dir: str bank_identifier: Optional[str] = None bank_password: Optional[str] = None mailgun_api_key: Optional[str] = None @@ -152,6 +154,7 @@ def get_config(account: str) -> Config: section = config[account] budget_id = section["budget"] token = section["token"] + screenshot_dir = section.get("screenshot_dir") if account == "DEFAULT": ynab_account_id = "" else: @@ -174,6 +177,7 @@ def get_config(account: str) -> Config: ynab_account_id, budget_id, token, + screenshot_dir, bank_identifier, bank_password, mailgun_api_key, diff --git a/pyproject.toml b/pyproject.toml index e1ab074..5befb4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ofx-processor" -version = "4.4.3" +version = "4.4.4" description = "Personal ofx processor" readme = "README.md" authors = ["Gabriel Augendre "] diff --git a/tests/samples/config.ini b/tests/samples/config.ini index aafe56d..e339d48 100644 --- a/tests/samples/config.ini +++ b/tests/samples/config.ini @@ -1,6 +1,7 @@ [DEFAULT] token = budget = +screenshot_dir = /tmp [bpvf] account =