From 6085c3439c704a1967e2e9aa07c21529f0d8bece Mon Sep 17 00:00:00 2001 From: Paul Pillot Date: Thu, 18 Aug 2022 19:55:26 -0400 Subject: [PATCH 1/3] fix: wrong test on FLASK_DEBUG flag The .get(FLASK_DEBUG, False) statement always evaluates to truthy. The .get() statement must be evaluated outside of the if clause (until we can use the walrus operator with python>=3.10) Also, wrap import in try/except block for robustness as debugpy is installed via the dev dockerfile. --- chord_drs/app.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/chord_drs/app.py b/chord_drs/app.py index cfb1500..1229b2f 100644 --- a/chord_drs/app.py +++ b/chord_drs/app.py @@ -46,9 +46,13 @@ # # debugger section # Ensure 'debugpy' is installed (via requirements.txt or manually) -if os.environ.get('FLASK_DEBUG', False): - import debugpy - DEBUGGER_PORT = int(os.environ.get('DEBUGGER_PORT', 5678)) - debugpy.listen(("0.0.0.0", DEBUGGER_PORT)) - print('Attached') -# # end debugger section \ No newline at end of file +DEBUG = os.environ.get('FLASK_DEBUG', False) +if DEBUG: + try: + import debugpy + DEBUGGER_PORT = int(os.environ.get('DEBUGGER_PORT', 5678)) + debugpy.listen(("0.0.0.0", DEBUGGER_PORT)) + print('Debugger Attached') + except ImportError as e: + print("Module debugpy not found. Run pip install debugpy to enable VSCode debugging") +# # end debugger section From d936cf884c32ce7a1f4c007f83c18f71233ac72e Mon Sep 17 00:00:00 2001 From: Paul Pillot Date: Thu, 18 Aug 2022 19:57:21 -0400 Subject: [PATCH 2/3] bump version number --- chord_drs/package.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chord_drs/package.cfg b/chord_drs/package.cfg index 7b3a1c1..e8f8de6 100644 --- a/chord_drs/package.cfg +++ b/chord_drs/package.cfg @@ -1,5 +1,5 @@ [package] name = chord_drs -version = 0.5.2 +version = 0.5.3 authors = Simon Chénard, David Lougheed author_emails = simon.chenard2@mcgill.ca, david.lougheed@mail.mcgill.ca From fe4982dccf65e3929a479e342cee206418fb8ab9 Mon Sep 17 00:00:00 2001 From: Paul Pillot Date: Mon, 22 Aug 2022 08:22:11 -0400 Subject: [PATCH 3/3] Remove var declaration. Improve logs legibility. --- chord_drs/app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chord_drs/app.py b/chord_drs/app.py index 1229b2f..080f55e 100644 --- a/chord_drs/app.py +++ b/chord_drs/app.py @@ -52,7 +52,7 @@ import debugpy DEBUGGER_PORT = int(os.environ.get('DEBUGGER_PORT', 5678)) debugpy.listen(("0.0.0.0", DEBUGGER_PORT)) - print('Debugger Attached') - except ImportError as e: - print("Module debugpy not found. Run pip install debugpy to enable VSCode debugging") + print('\nDebugger Attached\n') + except ImportError: + print("\nWARNING Module debugpy not found. To enable VSCode debugging, run:\n\tpip install debugpy\n") # # end debugger section