Helpers
helpers ¶
A module for managing file downloads with progress tracking in the console.
This module provides functionality for downloading files with visual progress indicators using the Rich library. It includes a signal handler for graceful interruption and a DownloadProgressBar class for concurrent file downloads with progress tracking.
Classes:
Name | Description |
---|---|
DownloadProgressBar: A class that provides visual progress tracking for file downloads. |
|
Functions:
Name | Description |
---|---|
handle_sigint: Signal handler for SIGINT |
console (Console): Rich Console instance for output rendering. done_event (Event): Threading Event used for signaling download interruption. |
DownloadProgressBar ¶
DownloadProgressBar()
A progress bar for downloading files.
This class provides a visual progress indicator for file downloads using the Rich library. It supports downloading multiple files concurrently with a progress bar showing download speed, completion percentage, and elapsed time.
Attributes:
Name | Type | Description |
---|---|---|
progress |
Progress
|
A Rich Progress instance configured with custom columns for displaying download information. |
Examples:
>>> downloader = DownloadProgressBar()
>>> urls = ['http://example.com/file1.zip', 'http://example.com/file2.zip']
>>> downloader.download(urls, '/path/to/destination')
Source code in eos_downloader/helpers/__init__.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
download ¶
download(urls: Iterable[str], dest_dir: str) -> None
Download files from URLs concurrently to a destination directory.
This method downloads files from the provided URLs in parallel using a thread pool, displaying progress for each download in the console.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
urls
|
Iterable[str]
|
An iterable of URLs to download files from. |
required |
dest_dir
|
str
|
The destination directory where files will be saved. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Examples:
>>> downloader = DownloadProgressBar()
>>> urls = ["http://example.com/file1.txt", "http://example.com/file2.txt"]
>>> downloader.download(urls, "/path/to/destination")
Source code in eos_downloader/helpers/__init__.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
handle_sigint ¶
handle_sigint(signum: Any, frame: Any) -> None
Signal handler for SIGINT (Ctrl+C).
This function sets the done_event flag when SIGINT is received, allowing for graceful termination of the program.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signum
|
Any
|
Signal number. |
required |
frame
|
Any
|
Current stack frame object. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in eos_downloader/helpers/__init__.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|