Compare commits

...

14 commits

10 changed files with 862 additions and 534 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
layout python3

1
.gitignore vendored
View file

@ -228,3 +228,4 @@ dmypy.json
.idea
.vscode
.direnv

1
.tool-versions Normal file
View file

@ -0,0 +1 @@
python 3.11.2

View file

@ -1,15 +1,15 @@
FROM debian:bullseye AS downloader
FROM debian:bookworm AS downloader
WORKDIR /app
RUN apt-get update && apt-get install -y wget
ARG GECKODRIVER_VERSION="v0.30.0"
ARG GECKODRIVER_VERSION="v0.33.0"
ARG GECKODRIVER_FILENAME="geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz"
RUN wget -q https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/$GECKODRIVER_FILENAME \
&& tar xvf $GECKODRIVER_FILENAME \
&& rm $GECKODRIVER_FILENAME
FROM python:3.10-slim-bullseye as final
FROM python:3.11-slim-bookworm as final
RUN apt-get update && apt-get install -y firefox-esr
COPY --from=downloader /app/geckodriver /usr/local/bin/geckodriver
ARG OFX_VERSION
RUN pip install ofx-processor==$OFX_VERSION
RUN pip --disable-pip-version-check install --quiet ofx-processor==$OFX_VERSION
CMD ["ynab", "lcl", "--download"]

BIN
error_download_lcl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

View file

@ -1,3 +1,4 @@
import os
import time
from pathlib import Path
@ -35,6 +36,14 @@ class LclDownloader:
self.selenium.implicitly_wait(30)
def download(self) -> str:
try:
return self._download()
except Exception:
screenshot = Path(self.config.screenshot_dir) / "error_download_lcl.png"
self.selenium.save_screenshot(screenshot)
raise
def _download(self) -> str:
selenium = self.selenium
click.secho("Logging in to LCL...", fg="blue")
@ -53,12 +62,22 @@ class LclDownloader:
self._click(By.CLASS_NAME, "app-cta-button")
click.secho("Logged in!", fg="green")
retry = True
while retry:
try:
self._click(By.CSS_SELECTOR, ".app-cta-button--primary")
click.secho("Dismissing welcome screen...", fg="blue")
time.sleep(1)
except NoSuchElementException:
click.secho("No welcome screen found.", fg="blue")
retry = False
try:
self._click(By.CSS_SELECTOR, "nav.menu-legacy button")
self._click(By.CSS_SELECTOR, ".menu-link.to-legacy")
self._click(By.CSS_SELECTOR, ".burger-menu-content")
self._click(By.CSS_SELECTOR, ".return-legacy-button")
click.secho("Going back to legacy version...", fg="blue")
except NoSuchElementException:
click.secho("Already on legacy version.", fg="blue")
click.secho("Probably already on legacy version.", fg="blue")
click.secho("Navigating through archives...", fg="blue")
self._click(By.ID, "linkSynthese")

View file

@ -17,6 +17,7 @@ def get_default_config():
default_config["DEFAULT"] = {
"token": "<YOUR API TOKEN>",
"budget": "<YOUR BUDGET ID>",
"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,

1340
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "ofx-processor"
version = "4.3.0"
version = "4.4.6"
description = "Personal ofx processor"
readme = "README.md"
authors = ["Gabriel Augendre <gabriel@augendre.info>"]
@ -20,15 +20,14 @@ classifiers = [
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Utilities",
]
[tool.poetry.dependencies]
python = ">=3.8,<4"
python = ">=3.10,<4"
ofxtools = ">=0.9.4"
click = ">=8.0.3"
dateparser = ">=1.1.0"
@ -39,7 +38,7 @@ python-telegram-bot = {version = ">=20.0a4", allow-prereleases = true}
[tool.poetry.dev-dependencies]
pytest = ">=6.0.1"
pytest-cov = ">=3.0.0"
invoke = ">=1.6.0"
invoke = ">=2.0.0"
pre-commit = ">=2.15.0"
tox = ">=3.24.4"
pdbpp = ">=0.10.3"
@ -57,12 +56,12 @@ profile = "black"
legacy_tox_ini = """
[tox]
isolated_build = true
envlist = py38, py39, py310
envlist = py310, py311
[testenv]
whitelist_externals = poetry
allowlist_externals = poetry
commands =
poetry install --remove-untracked
poetry install --sync
poetry run inv test
"""

View file

@ -1,6 +1,7 @@
[DEFAULT]
token = <YOUR API TOKEN>
budget = <YOUR BUDGET ID>
screenshot_dir = /tmp
[bpvf]
account = <YOUR BPVF ACCOUNT ID>