mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 02:54:16 +02:00
fix: not internet connection scenario when reading installed and searching
This commit is contained in:
16
bauh/commons/internet.py
Normal file
16
bauh/commons/internet.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import logging
|
||||
|
||||
import requests
|
||||
|
||||
from bauh.api.http import HttpClient
|
||||
|
||||
|
||||
def is_available(client: HttpClient, logger: logging.Logger) -> bool:
|
||||
try:
|
||||
client.get('https://google.com')
|
||||
return True
|
||||
except requests.exceptions.ConnectionError:
|
||||
if logger:
|
||||
logger.warning('Internet connection seems to be off')
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user