diff --git a/bauh/api/http.py b/bauh/api/http.py index 0d04e558..fc65d165 100644 --- a/bauh/api/http.py +++ b/bauh/api/http.py @@ -1,6 +1,7 @@ import logging import time import traceback +from typing import Optional import requests import yaml @@ -17,7 +18,7 @@ class HttpClient: self.sleep = sleep self.logger = logger - def get(self, url: str, params: dict = None, headers: dict = None, allow_redirects: bool = True, ignore_ssl: bool = False, single_call: bool = False, session: bool = True) -> requests.Response: + def get(self, url: str, params: dict = None, headers: dict = None, allow_redirects: bool = True, ignore_ssl: bool = False, single_call: bool = False, session: bool = True) -> Optional[requests.Response]: cur_attempts = 1 while cur_attempts <= self.max_attempts: @@ -44,7 +45,7 @@ class HttpClient: return res if single_call: - return + return res if self.sleep > 0: time.sleep(self.sleep) diff --git a/bauh/gems/flatpak/worker.py b/bauh/gems/flatpak/worker.py index fe1e0403..80d48885 100644 --- a/bauh/gems/flatpak/worker.py +++ b/bauh/gems/flatpak/worker.py @@ -87,7 +87,7 @@ class FlatpakAsyncDataLoader(Thread): self.api_cache.add(self.app.id, loaded_data) self.persist = self.app.supports_disk_cache() else: - self.logger.warning("Could not retrieve app data for id '{}'. Server response: {}. Body: {}".format(self.app.id, res.status_code, res.content.decode())) + self.logger.warning("Could not retrieve app data for id '{}'. Server response: {}. Body: {}".format(self.app.id, res.status_code if res else '?', res.content.decode() if res else '?')) except: self.logger.error("Could not retrieve app data for id '{}'".format(self.app.id)) traceback.print_exc()