Meteoalarm - obsługa wyjątku braku danych

master
sq9atk 2023-11-19 13:19:00 +01:00
rodzic 4a26950146
commit 08aeffc152
2 zmienionych plików z 6 dodań i 4 usunięć

Wyświetl plik

@ -397,6 +397,7 @@ calendarsq9atk = CalendarSq9atk(
modules = [
activitymap, # marker na mapie wx.ostol.pl
openweathersq9atk, # prognoza pogody
meteoalarmsq9atk, # meteoalarm.pl
imgwpodestsq9atk, # wodowskazy
airpollutionsq9atk, # zanieczyszczenia powietrza z GIOŚ
#airlysq9atk, # zanieczyszczenia powietrza z Airly

Wyświetl plik

@ -76,12 +76,11 @@ class MeteoalarmSq9atk(SR0WXModule):
html = self.getHtmlFromUrl(self.__service_url + str(self.__region_id))
data = self.findDataInHtml(html)
level = data[0]
warnings = data[1]
message = ''
if level and len(warnings) > 0:
try:
level = data[0]
warnings = data[1]
message += " ".join([
' _ zagrozenia_meteorologiczne_dla_wojewodztwa ',
self.__regions[self.__region_id],
@ -91,6 +90,8 @@ class MeteoalarmSq9atk(SR0WXModule):
' '.join([self.__levels[level]]),
' _ '
])
except:
None
return {
"message": message,