Skip to content

Commit

Permalink
[B] Added missing params validation, Version 0.1.7
Browse files Browse the repository at this point in the history
- added retries and retry_sec parameter validation
- updated missing params in readme
- bumped version from 0.1.6 to 0.1.7
  • Loading branch information
dwojtasik committed May 15, 2023
1 parent 1bd39c6 commit e5ad1f8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
14 changes: 10 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ Command line

.. code-block:: text
usage: qget [-h] [-o FILEPATH] [-f] [-a AUTH] [--no-verify] [--no-mock] [-H HEADER]
[-c MAX_CONNECTIONS] [--test CONNECTION_TEST_SEC] [--bytes CHUNK_BYTES]
[--part MAX_PART_MB] [--limit LIMIT] [--tmp TMP_DIR] [--debug] [-v]
usage: qget [-h] [-o FILEPATH] [-f] [-a AUTH] [--no-verify] [--no-mock]
[--proxy PROXY_URL] [-H HEADER] [-c MAX_CONNECTIONS]
[--test CONNECTION_TEST_SEC] [--bytes CHUNK_BYTES] [--part MAX_PART_MB]
[--retries RETRIES] [--retry_sec RETRY_SEC] [--limit LIMIT] [--tmp TMP_DIR]
[--debug] [-v]
url
Downloads resource from given URL in buffered parts using asynchronous HTTP connections
Expand Down Expand Up @@ -297,6 +299,10 @@ supplied by user is use as a top limit for calculated value.
History
=======
0.1.7 (2023-05-15)
------------------
- Added retries and retry_sec parameter validation.

0.1.6 (2023-05-15)
------------------
- Fixed multiple logging handlers created with multiple qget calls.
Expand Down Expand Up @@ -335,4 +341,4 @@ History
------------------
- Initial version.

.. |latest_version| replace:: 0.1.6
.. |latest_version| replace:: 0.1.7
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:: Run this in anaconda3
::=========================

set VERSION=0.1.6
set VERSION=0.1.7

::32bit
set CONDA_FORCE_32BIT=1
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

source ~/anaconda3/etc/profile.d/conda.sh

VERSION=0.1.6
VERSION=0.1.7

#32bit
export CONDA_FORCE_32BIT=1
Expand Down
2 changes: 1 addition & 1 deletion qget/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:copyright: (c) 2022 by Dominik Wojtasik.
:license: Apache2, see LICENSE for more details.
"""
__version__ = "0.1.6"
__version__ = "0.1.7"

from qget.qget_aio import ProgressState, qget, qget_coro

Expand Down
14 changes: 12 additions & 2 deletions qget/qget_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,13 @@ def _validate_paths(filepath: str, override: bool, tmp_dir: str) -> None:


def _validate_settings(
proxy_url: str, max_connections: int, connection_test_sec: int, chunk_bytes: int, max_part_mb: float
proxy_url: str,
max_connections: int,
connection_test_sec: int,
chunk_bytes: int,
max_part_mb: float,
retries: int,
retry_sec: int,
) -> None:
"""Validates download settings. Raises error if some arguments are invalid.
Expand All @@ -456,6 +462,10 @@ def _validate_settings(
raise ValueError(f"Parameter chunk_bytes has to have positive value. Actual value: {chunk_bytes}.")
if max_part_mb <= 0:
raise ValueError(f"Parameter max_part_mb has to have positive value. Actual value: {max_part_mb}.")
if retries < 0:
raise ValueError(f"Parameter retries cannot be negative. Actual value: {retries}.")
if retry_sec <= 0:
raise ValueError(f"Parameter retry_sec has to have positive value. Actual value: {retry_sec}.")


def _parse_limit(limit: str) -> int:
Expand Down Expand Up @@ -672,7 +682,7 @@ async def qget_coro(
tmp_dir = tempfile.gettempdir()

_validate_paths(filepath, override, tmp_dir)
_validate_settings(proxy_url, max_connections, connection_test_sec, chunk_bytes, max_part_mb)
_validate_settings(proxy_url, max_connections, connection_test_sec, chunk_bytes, max_part_mb, retries, retry_sec)
limit_bps = _parse_limit(limit)

basic_auth = None
Expand Down

0 comments on commit e5ad1f8

Please sign in to comment.