diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index adbbc00..548f631 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -6,7 +6,7 @@ name: Upload Python Package on: push: {} - + pull_request: {} release: @@ -17,7 +17,7 @@ jobs: name: Code QA runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: pip install black flake8 isort - run: black --version - run: isort --version @@ -38,7 +38,7 @@ jobs: needs: quality steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/setup-python@v2 with: @@ -63,7 +63,7 @@ jobs: needs: checks steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v2 diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 3b15919..c4150a3 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,14 @@ Changelog ========= +Version 2.13 +----------- +* Fixed missing exception case that could lead to empty files + +Version 2.12 +----------- +* Removed URL reading from file .hdarc + Version 2.0 ----------- * Updated version compatible with HDA v2 diff --git a/docs/source/conf.py b/docs/source/conf.py index d2f13aa..7782a74 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -15,8 +15,8 @@ copyright = "2023, ECMWF" author = "ECMWF" -release = "2.11" -version = "2.11" +release = "2.13" +version = "2.13" # -- General configuration diff --git a/hda/api.py b/hda/api.py index 30f194a..5567d37 100644 --- a/hda/api.py +++ b/hda/api.py @@ -317,14 +317,12 @@ def __init__( url=os.environ.get("HDA_URL"), user=os.environ.get("HDA_USER"), password=os.environ.get("HDA_PASSWORD"), - verify=None, + verify=True, path=None, ): credentials = { - "url": url or BROKER_URL, "user": None, - "password": None, - "verify": True, + "password": None } dotrc = path or os.environ.get("HDA_RC", os.path.expanduser("~/.hdarc")) @@ -336,25 +334,19 @@ def __init__( if config.get(key): credentials[key] = config.get(key) - if url is not None: - credentials["url"] = url - if user is not None: credentials["user"] = user if password is not None: credentials["password"] = password - if verify is not None: - credentials["verify"] = verify - if credentials["user"] is None or credentials["password"] is None: raise ConfigurationError("Missing or incomplete configuration") - self.url = credentials["url"] + self.url = url or BROKER_URL self.user = credentials["user"] self.password = credentials["password"] - self.verify = credentials["verify"] + self.verify = verify class Client(object): @@ -775,7 +767,7 @@ def stream(self, download_id, size, download_dir): total += len(chunk) pbar.update(len(chunk)) - except requests.exceptions.ConnectionError as e: + except requests.exceptions.RequestException as e: logger.error("Download interrupted: %s" % (e,)) finally: r.close() diff --git a/tests/custom_config.txt b/tests/custom_config.txt index 78d27c9..dec5de8 100644 --- a/tests/custom_config.txt +++ b/tests/custom_config.txt @@ -1,3 +1,2 @@ -url: TESTURL user: TESTUSER password: TESTPASSWORD diff --git a/tests/test_hda.py b/tests/test_hda.py index 8acc3b7..0ac8d65 100644 --- a/tests/test_hda.py +++ b/tests/test_hda.py @@ -56,7 +56,6 @@ def test_custom_password_config(): def test_custom_path_config(): config = Configuration(user=None, password=None, path=CUSTOM_HDRRC) c = Client(config=config) - assert c.config.url == "TESTURL" assert c.config.user == "TESTUSER" assert c.config.password == "TESTPASSWORD" @@ -65,7 +64,6 @@ def test_custom_path_config(): def test_mixed_config(): config = Configuration(user="TU", password="TP", path=CUSTOM_HDRRC) c = Client(config=config) - assert c.config.url == "TESTURL" assert c.config.user == "TU" assert c.config.password == "TP"