From fd16b2c94dc19cb21237c5d7dd3f1b67023bbff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric?= Date: Mon, 13 Jan 2025 15:32:48 +0100 Subject: [PATCH] Update ohcapi.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit catch an exception when internet is not available Signed-off-by: Frédéric --- pwnagotchi/plugins/default/ohcapi.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pwnagotchi/plugins/default/ohcapi.py b/pwnagotchi/plugins/default/ohcapi.py index e7d6f541..97c00e2b 100644 --- a/pwnagotchi/plugins/default/ohcapi.py +++ b/pwnagotchi/plugins/default/ohcapi.py @@ -70,7 +70,12 @@ class ohcapi(plugins.Plugin): return # Check if the internet is still available by pinging Google - response = requests.get('https://www.google.com', timeout=5) + try: + response = requests.get('https://www.google.com', timeout=5) + except requests.ConnectionError: + self.internet_active = False + return + if response.status_code == 200: self.internet_active = True else: