Show warnings on start -l if settings contains production-unsafe values. Resolves #1732

This commit is contained in:
Griatch 2019-09-23 23:22:56 +02:00
parent 70da95ef68
commit 37452e2a43
3 changed files with 18 additions and 7 deletions

View file

@ -28,6 +28,7 @@ without arguments starts a full interactive Python console.
Attributes instead of `[None]`.
- Remove `pillow` requirement (install especially if using imagefield)
- Add Simplified Korean translation (user aceamro)
- Show warning on `start -l` if settings contains values unsafe for production.
## Evennia 0.9 (2018-2019)

View file

@ -85,7 +85,12 @@ def check_errors(settings):
def check_warnings(settings):
"""
Check deprecations that should produce warnings but which
Check conditions and deprecations that should produce warnings but which
does not stop launch.
"""
pass
if settings.DEBUG:
print(" [Devel: settings.DEBUG is True. Important to turn off in production.]")
if settings.IN_GAME_ERRORS:
print(" [Devel: settings.IN_GAME_ERRORS is True. Turn off in production.]")
if settings.ALLOWED_HOSTS == ["*"]:
print(" [Devel: settings.ALLOWED_HOSTS set to '*' (all). Limit in production.]")

View file

@ -1611,7 +1611,7 @@ def show_version_info(about=False):
django=django.get_version())
def error_check_python_modules():
def error_check_python_modules(show_warnings=False):
"""
Import settings modules in settings. This will raise exceptions on
pure python-syntax issues which are hard to catch gracefully with
@ -1619,6 +1619,9 @@ def error_check_python_modules():
python source files themselves). Best they fail already here
before we get any further.
Kwargs:
show_warnings (bool): If non-fatal warning messages should be shown.
"""
from django.conf import settings
@ -1634,11 +1637,13 @@ def error_check_python_modules():
from evennia.server import deprecations
try:
deprecations.check_errors(settings)
deprecations.check_warnings(settings)
except DeprecationWarning as err:
print(err)
sys.exit()
if show_warnings:
deprecations.check_warnings(settings)
# core modules
_imp(settings.COMMAND_PARSER)
_imp(settings.SEARCH_AT_RESULT)
@ -2113,11 +2118,11 @@ def main():
query_info()
elif option == "start":
init_game_directory(CURRENT_DIR, check_db=True)
error_check_python_modules()
error_check_python_modules(show_warnings=args.tail_log)
start_evennia(args.profiler, args.profiler)
elif option == "istart":
init_game_directory(CURRENT_DIR, check_db=True)
error_check_python_modules()
error_check_python_modules(show_warnings=args.tail_log)
start_server_interactive()
elif option == "ipstart":
start_portal_interactive()