Queer European MD passionate about IT
소스 검색

Catch Exceptions in web page requests.

Davte 4 년 전
부모
커밋
a56831733d
2개의 변경된 파일10개의 추가작업 그리고 9개의 파일을 삭제
  1. 1 1
      ciclopibot/__init__.py
  2. 9 8
      ciclopibot/ciclopi.py

+ 1 - 1
ciclopibot/__init__.py

@@ -3,7 +3,7 @@
 __author__ = "Davide Testa"
 __email__ = "davide@davte.it"
 __license__ = "GNU General Public License v3.0"
-__version__ = "1.2.1"
+__version__ = "1.2.2"
 __maintainer__ = "Davide Testa"
 __contact__ = "t.me/davte"
 

+ 9 - 8
ciclopibot/ciclopi.py

@@ -1582,14 +1582,15 @@ async def check_service_status(bot: davtelepot.bot.Bot,
         interval = interval.total_seconds()
     while 1:
         ciclopi_data = await ciclopi_web_page.get_page()
-        stations = _get_stations(
-            data=ciclopi_data,
-            location=default_location
-        )
-        bot.shared_data['ciclopi']['is_working'] = any(
-            station.is_active
-            for station in stations
-        )
+        if ciclopi_data is not None and not isinstance(ciclopi_data, Exception):
+            stations = _get_stations(
+                data=ciclopi_data,
+                location=default_location
+            )
+            bot.shared_data['ciclopi']['is_working'] = any(
+                station.is_active
+                for station in stations
+            )
         await asyncio.sleep(interval)