From a56831733dbd97cde3480c3a2cd26d8920fdd1cd Mon Sep 17 00:00:00 2001 From: Davte Date: Sun, 10 May 2020 23:54:23 +0200 Subject: [PATCH 1/2] Catch Exceptions in web page requests. --- ciclopibot/__init__.py | 2 +- ciclopibot/ciclopi.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ciclopibot/__init__.py b/ciclopibot/__init__.py index 0dc7a08..59befb5 100644 --- a/ciclopibot/__init__.py +++ b/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" diff --git a/ciclopibot/ciclopi.py b/ciclopibot/ciclopi.py index 1382f2d..e68044e 100644 --- a/ciclopibot/ciclopi.py +++ b/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) From 459d9cc2e412b95d89a25e83c2a2150c88cf7dd6 Mon Sep 17 00:00:00 2001 From: Davte Date: Sat, 6 Jun 2020 01:56:30 +0200 Subject: [PATCH 2/2] Typo. --- ciclopibot/__init__.py | 2 +- ciclopibot/messages.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ciclopibot/__init__.py b/ciclopibot/__init__.py index 59befb5..5cf741d 100644 --- a/ciclopibot/__init__.py +++ b/ciclopibot/__init__.py @@ -3,7 +3,7 @@ __author__ = "Davide Testa" __email__ = "davide@davte.it" __license__ = "GNU General Public License v3.0" -__version__ = "1.2.2" +__version__ = "1.2.3" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/ciclopibot/messages.py b/ciclopibot/messages.py index ef0a2d9..a80f087 100644 --- a/ciclopibot/messages.py +++ b/ciclopibot/messages.py @@ -70,7 +70,7 @@ default_ciclopi_messages = { }, 'command': { 'description': { - 'en': "CiloPi stations status", + 'en': "CicloPi stations status", 'it': "Stato delle stazioni CicloPi", }, 'reply_keyboard_button': {