download_retry.py
A simple Python command-line tool to repeatedly attempt downloading a binary file from a URL until successful or until a timeout is reached.
Features
- Downloads binary data from a given URL
- Skips SSL certificate validation by default (
--insecure true) - Retries every
delta_tseconds untilmax_tseconds have elapsed - Saves the result to a specified output file
- Returns exit code
0on success,1on failure
Requirements
- Python 3.6+
requestspackage
Install dependencies using:
pip install -r requirements.txt
Installation
Clone the repository.
git clone git@github.com:gilweis/download_retry.git
cd download_retry
Usage
python -m download_retry --url --delta_t --max_t --out <output_filename> [--insecure true|false]
Arguments
| Argument | Description | Example |
|---|---|---|
--url |
The URL to download from | https://example.com/file.bin |
--delta_t |
Time between retries in seconds | 5 |
--max_t |
Maximum total wait time in seconds | 60 |
--out |
Output filename | file.bin |
--insecure |
Skip SSL verification (true by default) |
true or false |
Examples
Default (insecure=True):
Skips SSL certificate verification:
python -m download_retry
--url "https://my.server.local/firmware.bin"
--delta_t 3
--max_t 60
--out firmware.bin
Enforce SSL certificate verification (insecure=False):
python -m download_retry
--url "https://secure.example.com/file.bin"
--delta_t 3
--max_t 60
--out secure.bin
--insecure false
Exit Codes
0: File downloaded successfully1: Failed to download within time limit
Testing
To run tests:
- Install test requirements:
pip install pytest
- Run tests:
pytest tests/
Build and Install
To build source and wheel distributions:
python -m build
If you don't have the build tool installed:
pip install build
To install the package locally:
pip install .
To upload to PyPI (optional):
pip install twine twine upload dist/*
Warning
By default, SSL certificate validation is disabled using --insecure true. This may expose you to man-in-the-middle attacks. Use --insecure false to enforce SSL verification when downloading from public or sensitive endpoints.
License
MIT License
Version
0.1.2
Metadata
Release files for download-retry 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| download_retry-0.1.2.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| download_retry-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / download_retry-0.1.2.tar.gz
| Download URL | download_retry-0.1.2.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c39b4a7117848c6b1742dceae7deb7c06d4ee860d5db68e8d8ce6ab07628f905
|
|
BLAKE2b-256 checksum How to use checksums |
829b304c9109ab92ac9fcb1b61c59e6f5733dffbd98eb9d842c6ce68ee06a497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / download_retry-0.1.2-py3-none-any.whl
| Download URL | download_retry-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60770ca4899635b72880eaa8f13c11164453198f4da0becd4ddad58dd05b5157
|
|
BLAKE2b-256 checksum How to use checksums |
100a92365226f6eea1afd082afb3b6d5637f2e756bdf924d454d911a58a3b32b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|