Files
bearhub/bauh/commons/internet.py
2022-12-12 07:44:27 -03:00

18 lines
333 B
Python

import socket
class InternetChecker:
def __init__(self, offline: bool):
self.offline = offline
def is_available(self) -> bool:
if self.offline:
return False
try:
socket.gethostbyname('google.com')
return True
except Exception:
return False