Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voltego: catch regenerated token #1383

Merged
merged 2 commits into from
Apr 3, 2024
Merged

Voltego: catch regenerated token #1383

merged 2 commits into from
Apr 3, 2024

Conversation

LKuemmel
Copy link
Contributor

Bei Voltego wird anscheinend nicht ein Token pro Client, sondern das letzte erzeugte gespeichert. Ein Kunde hatte mir seine Zugangsdaten zur Verfügung gestellt, dabei ist das Problem aufgetreten.Ist aber auch ein Problem, wenn jemand noch mit einer anderen Steuerung die Daten aus seinem Account abfragt, dann bekommt die openWB keine Daten mehr. Deshalb muss dann ein neuer Token generiert werden.

@LKuemmel LKuemmel added the bug Something isn't working label Jan 29, 2024
@LKuemmel LKuemmel requested a review from benderl January 29, 2024 13:00
benderl
benderl previously requested changes Feb 1, 2024
@@ -3,6 +3,7 @@
import logging
from typing import Dict
import pytz
import requests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Von dem kompletten Modul wird lediglich eine Fehlerklasse benötigt. Macht es nicht Sinn, dann auch nur diese zu importieren?

Suggested change
import requests
from requests.exceptions import HTTPError

# Bei Voltego wird anscheinend nicht ein Token pro Client, sondern das letzte erzeugte gespeichert.
try:
raw_prices = get_raw_prices()
except requests.exceptions.HTTPError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kann hier der HTTP Fehlercode weiter eingegrenzt werden? Ich vermute, dass ein 401 "Unauthorized" vom Server kommt. Bei anderen Stati, insbesondere 5xx macht es ja keinen Sinn, dann nochmal eine Anfrage zu schicken. Die wird dann vermutlich ebenfalls fehlschlagen.

Suggested change
except requests.exceptions.HTTPError:
except HTTPError as error:
if errore.response.status_code != 401:
raise error

(ungetestet!)

@LKuemmel LKuemmel added this to the 2.4.1 Step 2 milestone Mar 22, 2024
@LKuemmel LKuemmel merged commit 7d08015 into openWB:master Apr 3, 2024
1 check passed
@LKuemmel LKuemmel deleted the voltego branch April 3, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants