Catch exceptions when updating gauge values
This commit is contained in:
parent
2ddefe1154
commit
b59707d3a7
1 changed files with 13 additions and 10 deletions
|
@ -153,17 +153,20 @@ start_http_server(8090)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
for gauge, aks in gauges:
|
for gauge, aks in gauges:
|
||||||
offers: List[dict] = aks.get_offers()
|
try:
|
||||||
available_offers: List[dict] = filter(
|
offers: List[dict] = aks.get_offers()
|
||||||
lambda x: x["stock"] == "InStock", offers)
|
|
||||||
store: Optional[str]
|
|
||||||
|
|
||||||
if (store := settings.get("Store", fallback=defaults.get("Store", ""))):
|
|
||||||
available_offers: List[dict] = filter(
|
available_offers: List[dict] = filter(
|
||||||
lambda x: x["platform"] == store, available_offers)
|
lambda x: x["stock"] == "InStock", offers)
|
||||||
|
store: Optional[str]
|
||||||
|
|
||||||
best_offer: dict = min(
|
if (store := settings.get("Store", fallback=defaults.get("Store", ""))):
|
||||||
available_offers, key=lambda x: x["price"][currency]["price"])
|
available_offers: List[dict] = filter(
|
||||||
gauge.set(best_offer["price"][currency]["price"])
|
lambda x: x["platform"] == store, available_offers)
|
||||||
|
|
||||||
|
best_offer: dict = min(
|
||||||
|
available_offers, key=lambda x: x["price"][currency]["price"])
|
||||||
|
gauge.set(best_offer["price"][currency]["price"])
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error updating gauge value for {gauge._name}: {e}")
|
||||||
|
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
|
Loading…
Reference in a new issue