mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
[api.http] refactoring: String formatting method
This commit is contained in:
@@ -60,11 +60,11 @@ class HttpClient:
|
|||||||
self.logger.warning(f"The URL '{url}' has an invalid schema")
|
self.logger.warning(f"The URL '{url}' has an invalid schema")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
self.logger.error("Could not retrieve data from '{}'".format(url))
|
self.logger.error(f"Could not retrieve data from '{url}'")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.logger.warning("Could not retrieve data from '{}'".format(url))
|
self.logger.warning(f"Could not retrieve data from '{url}'")
|
||||||
|
|
||||||
def get_json(self, url: str, params: dict = None, headers: dict = None, allow_redirects: bool = True, session: bool = True):
|
def get_json(self, url: str, params: dict = None, headers: dict = None, allow_redirects: bool = True, session: bool = True):
|
||||||
res = self.get(url, params=params, headers=headers, allow_redirects=allow_redirects, session=session)
|
res = self.get(url, params=params, headers=headers, allow_redirects=allow_redirects, session=session)
|
||||||
@@ -86,7 +86,7 @@ class HttpClient:
|
|||||||
else:
|
else:
|
||||||
res = requests.get(**params)
|
res = requests.get(**params)
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
self.logger.info("Internet seems to be off. Could not reach '{}'".format(url))
|
self.logger.info(f"Internet seems to be off. Could not reach '{url}'")
|
||||||
return
|
return
|
||||||
|
|
||||||
if res.status_code == 200:
|
if res.status_code == 200:
|
||||||
|
|||||||
Reference in New Issue
Block a user