mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
18 lines
329 B
Python
18 lines
329 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("w3.org")
|
|
return True
|
|
except Exception:
|
|
return False
|