Skip to content

"Allow absolute occweb path" doesn't work on Windows #377

Description

@jeanconn

#369 doesn't work on windows and fails the unit test.

This looks to me because "/FOT/mission_planning/PRODUCTS/APPR_LOADS/2000/MAR/" isn't an "absolute path" on windows. If we want that string / path to be modified if supplied on windows, the #369 code probably just needs to be generalized to look for a string that starts with "/" instead of an "absolute path".

kadi\tests\test_occweb.py ..........F............                                                                            [100%]

============================================================ FAILURES =============================================================
__________________________________________________ test_get_occweb_dir_absolute ___________________________________________________

    @pytest.mark.skipif(not HAS_OCCWEB, reason="No access to OCCweb")
    def test_get_occweb_dir_absolute():
        """Test get_occweb_dir and get_occweb_page (which is called in the process)"""
        path = "/FOT/mission_planning/PRODUCTS/APPR_LOADS/2000/MAR/"
>       files_path = occweb.get_occweb_dir(path, cache=False)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

kadi\tests\test_occweb.py:126:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
kadi\occweb.py:375: in get_occweb_dir
    html = get_occweb_page(
kadi\occweb.py:337: in get_occweb_page
    req.raise_for_status()  # raise exception if not 200
    ^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Response [404]>

    def raise_for_status(self):
        """Raises :class:`HTTPError`, if one occurred."""

        http_error_msg = ""
        if isinstance(self.reason, bytes):
            # We attempt to decode utf-8 first because some servers
            # choose to localize their reason strings. If the string
            # isn't utf-8, we fall back to iso-8859-1 for all other
            # encodings. (See PR #3538)
            try:
                reason = self.reason.decode("utf-8")
            except UnicodeDecodeError:
                reason = self.reason.decode("iso-8859-1")
        else:
            reason = self.reason

        if 400 <= self.status_code < 500:
            http_error_msg = (
                f"{self.status_code} Client Error: {reason} for url: {self.url}"
            )

        elif 500 <= self.status_code < 600:
            http_error_msg = (
                f"{self.status_code} Server Error: {reason} for url: {self.url}"
            )

        if http_error_msg:
>           raise HTTPError(http_error_msg, response=self)
E           requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://occweb.cfa.harvard.edu/FOT/mission_planning/PRODUCTS/APPR_LOADS/2000/MAR

..\..\miniforge\envs\build\envs\ska3-matlab-2026.2rc2\Lib\site-packages\requests\models.py:1026: HTTPError
===================================================== short test summary info =====================================================
FAILED kadi/tests/test_occweb.py::test_get_occweb_dir_absolute - requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://occweb.cfa.harvard.edu/FOT/mission_planning/PRODUCT...
====================================== 1 failed, 216 passed, 1 xfailed in 292.52s (0:04:52) =======================================
(ska3-matlab-2026.2rc2)
jean@FLICKER CLANGARM64 ~/git/kadi (master)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions