[appimage] downloading database files from the cloud

This commit is contained in:
Vinicius Moreira
2019-10-11 13:35:04 -03:00
parent 9096fd8064
commit da12bc2086
2 changed files with 13 additions and 9 deletions

View File

@@ -16,14 +16,17 @@ class HttpClient:
self.sleep = sleep
self.logger = logger
def get(self, url: str, headers: dict = None):
def get(self, url: str, params: dict = None, headers: dict = None, allow_redirects: bool = True):
cur_attempts = 1
while cur_attempts <= self.max_attempts:
cur_attempts += 1
try:
args = {'timeout': self.timeout}
args = {'timeout': self.timeout, 'allow_redirects': allow_redirects}
if params:
args['params'] = params
if headers:
args['headers'] = headers
@@ -46,8 +49,8 @@ class HttpClient:
self.logger.warning("Could not retrieve data from '{}'".format(url))
def get_json(self, url: str, headers: dict = None):
res = self.get(url, headers=headers)
def get_json(self, url: str, params: dict = None, headers: dict = None, allow_redirects: bool = True):
res = self.get(url, params=params, headers=headers, allow_redirects=allow_redirects)
return res.json() if res else None
def get_content_length(self, url: str) -> str: