mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 22:24:16 +02:00
[web] handling internet off errors when downloading the suggestions
This commit is contained in:
@@ -2,6 +2,7 @@ import logging
|
|||||||
import traceback
|
import traceback
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import requests
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from bauh.api.http import HttpClient
|
from bauh.api.http import HttpClient
|
||||||
@@ -17,12 +18,17 @@ class SuggestionsDownloader:
|
|||||||
|
|
||||||
def download(self) -> dict:
|
def download(self) -> dict:
|
||||||
self.logger.info("Reading suggestions from {}".format(URL_SUGGESTIONS))
|
self.logger.info("Reading suggestions from {}".format(URL_SUGGESTIONS))
|
||||||
suggestions = self.http_client.get_yaml(URL_SUGGESTIONS)
|
try:
|
||||||
|
suggestions = self.http_client.get_yaml(URL_SUGGESTIONS)
|
||||||
|
|
||||||
if suggestions:
|
if suggestions:
|
||||||
self.logger.info("{} suggestions successfully read".format(len(suggestions)))
|
self.logger.info("{} suggestions successfully read".format(len(suggestions)))
|
||||||
else:
|
else:
|
||||||
self.logger.warning("Could not read suggestions from {}".format(URL_SUGGESTIONS))
|
self.logger.warning("Could not read suggestions from {}".format(URL_SUGGESTIONS))
|
||||||
|
|
||||||
|
except (requests.exceptions.ConnectionError, requests.exceptions.ConnectTimeout):
|
||||||
|
self.logger.warning("Internet seems to be off: it was not possible to retrieve the suggestions")
|
||||||
|
return {}
|
||||||
|
|
||||||
return suggestions
|
return suggestions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user