mdeweerd / MetersToHA

Get Meter Data into Home Automation systems
GNU General Public License v3.0
26 stars 8 forks source link

depuis docker install: erreur #18

Closed vingerha closed 6 months ago

vingerha commented 6 months ago

Ce soucis ressemble un peu l'autre. J'ai installé le container ubuntu avant avec

docker-compose run --rm meters-to-ha-ubuntu

et après démarrage du container, depuis son cli l'erreur suivant

root@1723bd79596c:/workdir# ./apps/meters_to_ha/meters_to_ha.py --grdf -c ./config.json  --run -l . -k
Traceback (most recent call last):
  File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 3375, in doWork
    gazpar_file = crawler.get_gazpar_file()
  File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 1956, in get_gazpar_file
    raise ValueError("No content")
ValueError: No content

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 3385, in doWork
    gazpar_file = crawler.get_gazpar_file()
  File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 1956, in get_gazpar_file
    raise ValueError("No content")
ValueError: No content

Le service log:

2024-02-28 11:47:37,447 : OK : "state_file" = "/workdir/apps/meters_to_ha/meters2ha_state.json"
2024-02-28 11:47:37,448 : OK : End loading Home Assistant configuration
2024-02-28 11:47:37,449 : ~~ :  Check availability of "geckodriver"+"firefox" or "chromedriver"+"chromium"
2024-02-28 11:47:37,580 : OK : Check firefox browser version
2024-02-28 11:47:37,582 : OK :  Found chromium binary
2024-02-28 11:47:37,592 : OK : Check Home Assistant connectivity
2024-02-28 11:47:37,803 : OK : Try starting Firefox. Start virtual display (Firefox).
2024-02-28 11:47:47,250 : OK : Setup Firefox profile
2024-02-28 11:47:47,441 : OK : Start Firefox
2024-02-28 11:47:47,442 : OK :
2024-02-28 11:47:55,959 : OK : Connexion au site GRDF
2024-02-28 11:47:57,828 : OK : Waiting for Password
2024-02-28 11:47:57,842 : OK : Waiting for Email
2024-02-28 11:47:58,653 : OK : Type Email
2024-02-28 11:47:59,433 : OK : Type Password
2024-02-28 11:48:00,064 : ~~ : Proceed with captcha resolution. 2Captcha https://2captcha.com/in.php?key=1f95e9.....47179bcea&method=userrecaptcha&googlekey=6LfNHKg.....LUFRFc4mNHj                                            au8gl4INB4bsyHy1&pageurl=https://login.monespace.grdf.fr:443&soft_id=3887
2024-02-28 11:48:00,491 : ~~ :  2Captcha Service response OK|75812497318
2024-02-28 11:48:00,494 : ~~ :  Wait 20s for 2Captcha
2024-02-28 11:48:20,879 : ~~ :  2Captcha Service response CAPCHA_NOT_READY
2024-02-28 11:48:20,881 : ~~ :  Wait 10s for 2Captcha
2024-02-28 11:48:31,136 : ~~ :  2Captcha Service response CAPCHA_NOT_READY
2024-02-28 11:48:31,139 : ~~ :  Wait 10s for 2Captcha
2024-02-28 11:48:41,444 : ~~ :  2Captcha Service response OK|03AFcWeA4cGkiGMvbustYcUpnZ036AveAd.....
2024-02-28 11:48:43,555 : OK : Automatic resolution succeeded. Wait for Button xpath://input[@value='Connexion'].
2024-02-28 11:48:43,556 : ~~ : Wait before clicking (1.1s).
2024-02-28 11:49:26,011 : WW : Click on connexionGet Data URL https://monespace.grdf.fr/api/e-conso/pce/consommation/informatives?dateDebut=2024-02-14&dateFin=2024-02-28&pceList[]=2596049201608                                            4Get data url second time in 5 secondsGet Data Content. No downloaded File. <pre> Element not found. This may be due to an issue with the captcha resolution. Check the log for other errors and                                             check your captcha solver configuration Traceback (most recent call last): -   File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 3375, in doWork -     gazpar_file = crawler.get_gazpar_f                                            ile() -   File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 1956, in get_gazpar_file -     raise ValueError("No content") - ValueError: No content
2024-02-28 11:49:26,012 : WW :  Encountered error -> Retrying once
2024-02-28 11:49:32,535 : OK : Waiting for cookie popup
2024-02-28 11:49:33,109 : OK : Click on deny
2024-02-28 11:49:34,321 : OK : Connexion au site GRDF
2024-02-28 11:49:36,208 : OK : Waiting for Password
2024-02-28 11:49:36,361 : OK : Waiting for Email
2024-02-28 11:49:36,781 : OK : Type Email
2024-02-28 11:49:37,137 : OK : Type Password
2024-02-28 11:49:37,741 : ~~ : Proceed with captcha resolution. 2Captcha https://2captcha.com/in.php?key=1f95e948c6b94dd81895a0247179bcea&method=userrecaptcha&googlekey=6LfNHKgZAAAAALUFRFc4mNHj                                            au8gl4INB4bsyHy1&pageurl=https://login.monespace.grdf.fr:443&soft_id=3887
2024-02-28 11:49:38,114 : ~~ :  2Captcha Service response OK|75812507843
2024-02-28 11:49:38,119 : ~~ :  Wait 20s for 2Captcha
2024-02-28 11:49:58,432 : ~~ :  2Captcha Service response OK|03AFcWeA49SuoHXFYuWF6c_2HNQ7puZ9bybjIx_93b9k......
2024-02-28 11:50:00,531 : OK : Automatic resolution succeeded. Wait for Button xpath://input[@value='Connexion'].
2024-02-28 11:50:00,532 : ~~ : Wait before clicking (1.1s).
2024-02-28 11:50:02,253 : OK : Click on connexion
2024-02-28 11:50:44,799 : EE : End of wait after connexion. Get Data URL https://monespace.grdf.fr/api/e-conso/pce/consommation/informatives?dateDebut=2024-02-14&dateFin=2024-02-28&pceList[]=25                                            960492016084Get data url second time in 5 secondsGet Data Content. No downloaded File. <pre> Element not found. This may be due to an issue with the captcha resolution. Check the log for other                                             errors and check your captcha solver configuration No content
2024-02-28 11:50:46,001 : OK : Close Browser
2024-02-28 11:50:46,019 : OK : Close Display
2024-02-28 11:50:46,021 : EE :  Ended with error : // re-run with '--display' option if you can

Testé avec 2captcha et capmonster Si j'utilise l'url depuis mon browser (https://monespace.grdf.fr/api/e-conso/pce/consommation/informatives?dateDebut=2024-02-14&dateFin=2024-02-28&pceList[]=2596049201608) ...je vois bien le json avec la comsommation

mdeweerd commented 6 months ago

Après un "Building 332.8s" j'étais dans le prompt "workdir" avec la commande donnée - j'ai tenté docker-compose run --rm meters-to-ha-run-ubuntu ensuite.

J'obtiens le même résultat - cela semble répétable.

Avec:

docker-compose run --rm meters-to-ha-grdf

le conteneur démarre au bout de 43 secondes et j'abouti sur un timeout pendant la récupération.

Sous l'addon HAOS, le script tourne tous les jours avec succès.

Le rapport est légèrement différent - "Get Data URL" ne se trouve pas sur la même ligne que "Click on connexion" et on a un "End of wait after connexion":

2024-02-27 21:28:43,962 : ~~ : Wait before clicking (1.6s).
2024-02-27 21:28:47,010 : OK : Click on connexion
2024-02-27 21:29:13,162 : -- : End of wait after connexion. Get Data URL https://monespace.grdf.fr/api/e-conso/pce/consommation/informatives?

Voilà pour les premières analyses - après il me reset à trouver du temps pour creuser un peu plus...

vingerha commented 6 months ago

Merci...et grdf est maintenant hors-ligne (maintenance)

vingerha commented 6 months ago

Le soucis est dans le container, si j'utilise le script sous ubuntu (avec les modules selon dockerfile) ça marche. Je continue ma recherche

vingerha commented 6 months ago

Testé

mdeweerd commented 6 months ago

Sur ubuntu on passe par firefox de mémoire, c'est déjà une différence importante. Ensuite, les évolutions des navigateurs et du site et autres impactent le process.

vingerha commented 6 months ago

OK, et avec chromium sur ubuntu la même erreur que sur Debian (dessou). En essayant de le ressoudre encore plus d'erreurs. Trops de temps et pas de prio pour moi...je reste sur Alpine en attendant une solution Ubuntu si tu le fait...mais hônettement...entretenir 3 versions docker...je ne le ferais pas :)


Traceback (most recent call last):
  File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 3363, in doWork
    crawler.init()
  File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 524, in init
    self.init_chromium()
  File "/workdir/./apps/meters_to_ha/meters_to_ha.py", line 773, in init_chromium
    chromeService = webdriver.chrome.service.Service(
TypeError: Service.__init__() got an unexpected keyword argument 'log_output'
mdeweerd commented 6 months ago

Le dockers c'est principalement pour valider ce qui fonctionne sur l'un et l'autre car on peut toujours installer le script sans docker. C'était comme cela dans le dépôt d'origine (il n'y avait pas ces configs toutefois).

vingerha commented 6 months ago

compris mais pour le moment c'est que 'Alpine' qui marche (ce que je vois) et fixer Debian et/ou Ubuntu ensus ...du boulot :)

mdeweerd commented 6 months ago

Je ne le prend pas comme une priorité puisque Alpine fonctionne et si qqn a un problème sur Ubuntu/debian en natif il pourra voir pour le debogue...

vingerha commented 6 months ago

merci pour tous!!