download_file

Contents

download_file#

SurVigilance.ui.scrapers.download_file(url: str, download_dir: str = 'data/faers', timeout: int = 600, callback: Callable[[dict], None] | None = None, num_retries: int = 5) str[source]#

Save a file from a direct link using requests module.

Parameters#

url: str

Direct URL to the file.

download_dir: str

Directory where the file should be saved.

timeout: int

Max seconds to wait for the download (default 600s or 10 mins).

callback: callable, optional

Callable to receive UI/status events, called with a dict. This is essential to show progress to user.

num_retries: int

Number of retries for data download after which error is thrown (default 5).

Returns#

Full path to the saved file as a string.