Update ohcapi.py

catch an exception when internet is not available

Signed-off-by: Frédéric <fmatray@users.noreply.github.com>
This commit is contained in:
Frédéric
2025-01-13 15:32:48 +01:00
committed by GitHub
parent a4d5930477
commit fd16b2c94d

View File

@ -70,7 +70,12 @@ class ohcapi(plugins.Plugin):
return return
# Check if the internet is still available by pinging Google # Check if the internet is still available by pinging Google
try:
response = requests.get('https://www.google.com', timeout=5) response = requests.get('https://www.google.com', timeout=5)
except requests.ConnectionError:
self.internet_active = False
return
if response.status_code == 200: if response.status_code == 200:
self.internet_active = True self.internet_active = True
else: else: