fix: not internet connection scenario when reading installed and searching

This commit is contained in:
Vinicius Moreira
2019-09-24 12:26:33 -03:00
parent 3c51046668
commit e56ecc8f49
14 changed files with 160 additions and 72 deletions

16
bauh/commons/internet.py Normal file
View 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