diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-04-15 10:34:53 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-04-15 10:34:53 +0100 |
commit | ece66a4e9e5d46baa0376bd972f2d4e718b91062 (patch) | |
tree | 1c9e73f1e5cc4a78c36dcfe414cbceb63a4e2187 /src/backend/checkenv.py | |
parent | 44f62d1aba2751d2d2909cc6eec5cb659a8ecde4 (diff) |
check for internet connectivity, and stop execution if there is none
Diffstat (limited to 'src/backend/checkenv.py')
-rw-r--r-- | src/backend/checkenv.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/backend/checkenv.py b/src/backend/checkenv.py index c8152bf..124ba76 100644 --- a/src/backend/checkenv.py +++ b/src/backend/checkenv.py @@ -3,6 +3,19 @@ import os import subprocess import sisyphus.getenv +import urllib.request + + +def connectivity(): + is_online = int() + + try: + urllib.request.urlopen("http://www.google.com", timeout=5) + is_online = int(1) + except urllib.error.URLError: + is_online = int(0) + + return is_online def root(): |