From 29a6606a758cc72a58b692c39615d51e26cf97c2 Mon Sep 17 00:00:00 2001 From: Tai Lee Date: Tue, 6 Mar 2018 16:30:14 +1100 Subject: [PATCH] Improve list of included base and project settings, re #8 * Print actual `ixc_django_docker.settings` and project directories, to make it easier to find the files being included. * Only print a one line warning if `DONT_PRINT_SETTINGS` environment variable is defined. Put `DONT_PRINT_SETTINGS=1` in `.env.local` if you don't want to see the included settings printed on startup. The warning is there just as a reminder that we're missing out on this information, and how to get it back. --- ixc_django_docker/settings/__init__.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ixc_django_docker/settings/__init__.py b/ixc_django_docker/settings/__init__.py index 7b97984..5ac648e 100644 --- a/ixc_django_docker/settings/__init__.py +++ b/ixc_django_docker/settings/__init__.py @@ -53,11 +53,22 @@ def _(module, from_dir): optional(os.path.join(PROJECT_SETTINGS_DIR, 'local.py'))) # Tell users where settings are coming from. -print('BASE_SETTINGS:\n %s' % '\n '.join( - _(os.path.join(os.path.dirname(__file__), s), os.path.dirname(__file__)) - for s in BASE_SETTINGS)) -print('PROJECT_SETTINGS:\n %s' % '\n '.join( - _(os.path.join(PROJECT_DIR, s), PROJECT_DIR) for s in PROJECT_SETTINGS)) +if os.environ.get('DONT_PRINT_SETTINGS'): + print( + 'NOT printing actual base and project settings. Unset ' + '`DONT_PRINT_SETTINGS` to change.') +else: + print('BASE_SETTINGS (%s):\n %s' % ( + os.path.dirname(__file__), + '\n '.join( + _(os.path.join(os.path.dirname(__file__), s), os.path.dirname(__file__)) + for s in BASE_SETTINGS), + )) + print('PROJECT_SETTINGS (%s):\n %s' % ( + PROJECT_DIR, + '\n '.join( + _(os.path.join(PROJECT_DIR, s), PROJECT_DIR) for s in PROJECT_SETTINGS), + )) # Include base and project settings modules. include(*BASE_SETTINGS)