From 7c508d19759114c313d305ce99efd85203bda76e Mon Sep 17 00:00:00 2001 From: Paul Haesler Date: Tue, 24 Oct 2023 10:48:32 +1100 Subject: [PATCH] treat "n", "no", "f" and "false" in $PYDEV_DEBUG as explicit "No debugging". --- datacube_ows/startup_utils.py | 9 +++++---- docs/environment_variables.rst | 2 +- tests/test_startup.py | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/datacube_ows/startup_utils.py b/datacube_ows/startup_utils.py index 3331baf6..b9e9673e 100644 --- a/datacube_ows/startup_utils.py +++ b/datacube_ows/startup_utils.py @@ -50,10 +50,11 @@ def initialise_ignorable_warnings(): def initialise_debugging(log=None): # PYCHARM Debugging if os.environ.get("PYDEV_DEBUG"): - import pydevd_pycharm - pydevd_pycharm.settrace('172.17.0.1', port=12321, stdoutToServer=True, stderrToServer=True) - if log: - log.info("PyCharm Debugging enabled") + if os.environ["PYDEV_DEBUG"].lower() not in ("no", "false", "f", "n"): + import pydevd_pycharm + pydevd_pycharm.settrace('172.17.0.1', port=12321, stdoutToServer=True, stderrToServer=True) + if log: + log.info("PyCharm Debugging enabled") def before_send(event, hint): if 'exc_info' in hint: diff --git a/docs/environment_variables.rst b/docs/environment_variables.rst index a7b28b50..eaf51925 100644 --- a/docs/environment_variables.rst +++ b/docs/environment_variables.rst @@ -103,7 +103,7 @@ Dev Tools --------- PYDEV_DEBUG: - If set, activates PyDev remote debugging. + If set to anything other than "n", "f", "no" or "false" (case insensitive), activates PyDev remote debugging. DEFER_CFG_PARSE: If set, the configuration file is not read and parsed at startup. This diff --git a/tests/test_startup.py b/tests/test_startup.py index ea66134b..77c08c74 100644 --- a/tests/test_startup.py +++ b/tests/test_startup.py @@ -82,6 +82,12 @@ def test_initialise_nodebugging(monkeypatch): initialise_debugging() +def test_initialise_explicit_nodebugging(monkeypatch): + monkeypatch.setenv("PYDEV_DEBUG", "no") + from datacube_ows.startup_utils import initialise_debugging + initialise_debugging() + + def test_initialise_debugging(monkeypatch): monkeypatch.setenv("PYDEV_DEBUG", "YES") from datacube_ows.startup_utils import initialise_debugging