From 6ac2243a59dd0b8f247591833e8777337eedec53 Mon Sep 17 00:00:00 2001 From: ViliAu <36374215+ViliAu@users.noreply.github.com> Date: Thu, 15 Oct 2020 19:31:42 +0300 Subject: [PATCH] Update photon.py --- photon.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/photon.py b/photon.py index 6fd992c..75bd508 100644 --- a/photon.py +++ b/photon.py @@ -48,6 +48,18 @@ (red, white, red, white, red, white, red, white, red, white, red, white, red, white, end)) +# Test for Internet connectivity + +TEST_URL = "http://www.example.com" +timeout = 10 + +try: + request = requests.get(TEST_URL, timeout=timeout) + print("Connected to the Internet") +except (requests.ConnectionError, requests.Timeout): + print("No internet connection.") + quit() + try: from urllib.parse import urlparse # For Python 3 except ImportError: