Skip to content

Commit

Permalink
Deprecate PPP_CONFIG_DIR for specifying config path
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Nov 21, 2024
1 parent 9700076 commit 9051433
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 34 deletions.
31 changes: 5 additions & 26 deletions pyorbital/tests/test_tlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,39 +183,18 @@ def test_check_is_platform_supported_unknown(caplog):
assert expected3 in logoutput_lines[2]


#def test_get_config_path_ppp_config_set_but_not_pyorbital_future(mock, caplog, monkeypatch):
# """Test getting the config path."""
# monkeypatch.setenv("SATPY_CONFIG_PATH", "/path/to/satpy/etc")
# monkeypatch.setenv("PPP_CONFIG_DIR", "/path/to/old/mpop/config/dir")
#
# with caplog.at_level(logging.WARNING):
# res = _get_config_path()
#
# log_output = ("The use of PPP_CONFIG_DIR is no longer supported! " +
# "Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
# assert log_output in caplog.text
# assert res == PKG_CONFIG_DIR


def test_get_config_path_ppp_config_set_but_not_pyorbital_is_deprecated(caplog, monkeypatch):
"""Test getting the config path.
Here the case is tested when the new Pyorbital environment variable is not
set but the deprecated (old) Satpy/MPOP one is set.
"""
def test_get_config_path_ppp_config_set_but_not_pyorbital_future(caplog, monkeypatch):
"""Test getting the config path."""
monkeypatch.setenv("SATPY_CONFIG_PATH", "/path/to/satpy/etc")
monkeypatch.setenv("PPP_CONFIG_DIR", "/path/to/old/mpop/config/dir")

with caplog.at_level(logging.WARNING):
res = _get_config_path()

assert res == "/path/to/old/mpop/config/dir"

log_output = ("The use of PPP_CONFIG_DIR is deprecated and will be removed in version 1.9!" +
" Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")

log_output = ("The use of PPP_CONFIG_DIR is no longer supported! " +
"Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
assert log_output in caplog.text
assert res == PKG_CONFIG_DIR


def test_get_config_path_ppp_config_set_and_pyorbital(caplog, monkeypatch):
Expand Down
11 changes: 3 additions & 8 deletions pyorbital/tlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,11 @@ class TleDownloadTimeoutError(Exception):
def _get_config_path():
"""Get the config path for Pyorbital."""
if "PPP_CONFIG_DIR" in os.environ and "PYORBITAL_CONFIG_PATH" not in os.environ:
# XXX: Swap when pyorbital 1.9 is released
#LOGGER.warning(
# "The use of PPP_CONFIG_DIR is no longer supported!" +
# " Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
#LOGGER.debug("Using the package default for configuration: %s", PKG_CONFIG_DIR)
#return PKG_CONFIG_DIR
LOGGER.warning(
"The use of PPP_CONFIG_DIR is deprecated and will be removed in version 1.9!" +
"The use of PPP_CONFIG_DIR is no longer supported!" +
" Please use PYORBITAL_CONFIG_PATH if you need a custom config path for pyorbital!")
pyorbital_config_path = os.getenv("PPP_CONFIG_DIR", PKG_CONFIG_DIR)
LOGGER.debug("Using the package default for configuration: %s", PKG_CONFIG_DIR)
return PKG_CONFIG_DIR
else:
pyorbital_config_path = os.getenv("PYORBITAL_CONFIG_PATH", PKG_CONFIG_DIR)

Expand Down

0 comments on commit 9051433

Please sign in to comment.