diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f2bf026..48b321a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [0.9.1] +## [0.9.1] 2020 +### Improvements +- Internet availability checking code + ### Fixes - Arch - wrong dialog titles diff --git a/bauh/commons/internet.py b/bauh/commons/internet.py index 9cd86324..e860d831 100644 --- a/bauh/commons/internet.py +++ b/bauh/commons/internet.py @@ -1,13 +1,12 @@ -import subprocess -import traceback -from subprocess import Popen +import http.client as http_client def is_available() -> bool: + conn = http_client.HTTPConnection("www.google.com", timeout=5) try: - res = Popen(['ping', '-q', '-w1', '-c1', 'google.com'], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL) - res.wait() - return res.returncode == 0 + conn.request("HEAD", "/") + conn.close() + return True except: - traceback.print_exc() + conn.close() return False