qgis_deployment_toolbelt.utils.file_downloader module¶
- class qgis_deployment_toolbelt.utils.file_downloader.TruststoreAdapter(pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)¶
Bases:
HTTPAdapter
Custom HTTP transport adapter made to use local trust store.
Source: <https://stackoverflow.com/a/78265028/2556577> Documentation: <https://requests.readthedocs.io/en/latest/user/advanced/#transport-adapters>
- qgis_deployment_toolbelt.utils.file_downloader.download_remote_file_to_local(remote_url_to_download: str, local_file_path: Path, user_agent: str = 'QGISDeploymentToolbelt/0.35.3', content_type: str | None = None, chunk_size: int = 8192, timeout: tuple[int, int] = (800, 800), use_stream: bool = True) Path ¶
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.
- Parameters:
remote_url_to_download (str) – remote URL of the search index
local_file_path (Path) – local path to the index file
user_agent (str, optional) – user agent to use to perform the request. Defaults to f”{__title_clean__}/{__version__}”.
content_type (str | None, optional) – HTTP content-type. Defaults to None.
chunk_size (int, optional) – size of each chunk to read and write in bytes. Defaults to 8192.
timeout (tuple[int, int], optional) – custom timeout (request, response). Defaults to (800, 800).
use_stream (bool, optional) – Option to enable/disable streaming download. Defaults to True.
- Returns:
path to the local file (should be the same as local_file_path)
- Return type:
Path