geotribu_cli.utils.file_downloader module#
- class geotribu_cli.utils.file_downloader.BetterHTTPErrorProcessor#
Bases :
BaseHandler
- A custom processor for HTTP error to avoid raising exception when response code
is 40*. Especially for 401 (authentication issue).
Inspired by https://stackoverflow.com/a/7033063/2556577.
- Paramètres:
BaseHandler – base class
- http_error_401(request, response, code, msg, headers)#
Handle 401 responses.
- Paramètres:
request (
Request
) – request objectresponse (
HTTPResponse
) – response objectcode (
int
) – HTTP response codemsg (
str
) – messageheaders (
HTTPMessage
) – response headers
- Type renvoyé:
- Renvoie:
response object
- geotribu_cli.utils.file_downloader.download_remote_file_to_local(remote_url_to_download, local_file_path, expiration_rotating_hours=24, user_agent='GeotribuToolbelt/0.29.0', content_type=None, chunk_size=8192)#
Check if the local index file exists. If not, download the search index from remote URL. If it does exist, check if it has been modified.
- Paramètres:
remote_url_to_download (str) – remote URL of the file to download
local_file_path (Path) – local path to the file
expiration_rotating_hours (int, optional) – number in hours to consider the local file outdated. Defaults to 24.
user_agent (str, optional) – user agent to use to perform the request. Defaults to f »{__title_clean__}/{__version__} ».
content_type (str) – HTTP content-type.
chunk_size (int) – size of each chunk to read and write in bytes.
- Renvoie:
path to the local file (should be the same as local_file_path)
- Type renvoyé:
Path