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>

init_poolmanager(connections: int, maxsize: int, block: bool = False) None

Initializes a urllib3 PoolManager.

Parameters:
  • connections (int) – number of urllib3 connection pools to cache.

  • maxsize (int) – maximum number of connections to save in the pool.

  • block (bool, optional) – Block when no free connections are available.. Defaults to False.

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