Compare commits

..

No commits in common. "43b76772e114ef8bb98ba5fa432de609a6bd5208" and "a4eb23280f0e7773cb3e3c5d76d302945b7da6b3" have entirely different histories.

6 changed files with 17 additions and 24 deletions

1
.gitignore vendored
View file

@ -1,4 +1,3 @@
error_download_lcl.png
geckodriver.log geckodriver.log
# Created by https://www.gitignore.io/api/osx,pycharm,python # Created by https://www.gitignore.io/api/osx,pycharm,python

View file

@ -1,2 +1 @@
python 3.11.2 python 3.11.2
poetry latest

View file

@ -50,7 +50,7 @@ inv full-test
poetry version <major/minor/patch> poetry version <major/minor/patch>
git add . git add .
git commit git commit
inv tag $(poetry version -s) inv tag <version>
inv publish publish-docker inv publish publish-docker
``` ```

BIN
error_download_lcl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

View file

@ -1,4 +1,4 @@
import datetime import os
import time import time
from pathlib import Path from pathlib import Path
@ -27,7 +27,7 @@ class LclDownloader:
download_folder = Path.home() / "Downloads" download_folder = Path.home() / "Downloads"
self.download_folder = download_folder.resolve() self.download_folder = download_folder.resolve()
options = webdriver.FirefoxOptions() options = webdriver.FirefoxOptions()
options.add_argument("-headless") options.headless = True
options.set_preference("browser.download.dir", str(self.download_folder)) options.set_preference("browser.download.dir", str(self.download_folder))
options.set_preference( options.set_preference(
"browser.helperApps.neverAsk.saveToDisk", "application/x-ofx" "browser.helperApps.neverAsk.saveToDisk", "application/x-ofx"
@ -72,19 +72,20 @@ class LclDownloader:
click.secho("No welcome screen found.", fg="blue") click.secho("No welcome screen found.", fg="blue")
retry = False retry = False
self._click(By.CLASS_NAME, "extended-zone") try:
self._click(By.ID, "export-button") 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("Probably already on legacy version.", fg="blue")
end = datetime.date.today() - datetime.timedelta(days=1) click.secho("Navigating through archives...", fg="blue")
start = end - datetime.timedelta(days=9) self._click(By.ID, "linkSynthese")
self._click(By.CLASS_NAME, "picDl")
self._type_nth(By.CSS_SELECTOR, "input.range-picker-input", 0, start.strftime("%d/%m/%Y")) self._select(By.ID, "change", index=1)
self._type_nth(By.CSS_SELECTOR, "input.range-picker-input", 1, end.strftime("%d/%m/%Y")) self._select(By.ID, "DS", index=20)
self._click(By.ID, "MON04")
self._click(By.CSS_SELECTOR, "ui-desktop-select button") self._click(By.ID, "Valider")
self._click_nth(By.CSS_SELECTOR, "ui-select-list ul li", 2)
self._click(By.CLASS_NAME, "download-button")
click.secho("Found it!", fg="green") click.secho("Found it!", fg="green")
selenium.get("about:downloads") selenium.get("about:downloads")
return self._get_last_download_file_name() return self._get_last_download_file_name()
@ -92,15 +93,9 @@ class LclDownloader:
def _click(self, by: By, value: str): def _click(self, by: By, value: str):
self.selenium.find_element(by, value).click() self.selenium.find_element(by, value).click()
def _click_nth(self, by: By, value: str, idx: int):
self.selenium.find_elements(by, value)[idx].click()
def _select(self, by: By, value: str, index: int): def _select(self, by: By, value: str, index: int):
Select(self.selenium.find_element(by, value)).select_by_index(index) Select(self.selenium.find_element(by, value)).select_by_index(index)
def _type_nth(self, by: By, value: str, idx: int, value_to_type: str):
self.selenium.find_elements(by, value)[idx].send_keys(value_to_type)
def _get_last_download_file_name(self, wait_seconds: int = 30): def _get_last_download_file_name(self, wait_seconds: int = 30):
end_time = time.time() + wait_seconds end_time = time.time() + wait_seconds
while time.time() < end_time: while time.time() < end_time:

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "ofx-processor" name = "ofx-processor"
version = "4.5.0" version = "4.4.6"
description = "Personal ofx processor" description = "Personal ofx processor"
readme = "README.md" readme = "README.md"
authors = ["Gabriel Augendre <gabriel@augendre.info>"] authors = ["Gabriel Augendre <gabriel@augendre.info>"]