Skip to content

Commit

Permalink
treat "n", "no", "f" and "false" in $PYDEV_DEBUG as explicit "No debu…
Browse files Browse the repository at this point in the history
…gging".
  • Loading branch information
SpacemanPaul committed Oct 23, 2023
1 parent 57b6672 commit 7c508d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions datacube_ows/startup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/environment_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c508d1

Please sign in to comment.