python3: use exec(open(... to replace execfile (#39092)

This commit is contained in:
Frédéric Péters 2020-01-19 19:04:15 +01:00
parent f165c7d12d
commit 4f9bb8b161
3 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# This file is sourced by "execfile" from welco.settings
# This file is sourced by "exec(open(..." from welco.settings
import os
@ -10,12 +10,12 @@ INSTALLED_APPS += ('mellon',)
#
# hobotization (multitenant)
#
execfile('/usr/lib/hobo/debian_config_common.py')
exec(open('/usr/lib/hobo/debian_config_common.py').read())
#
# local settings
#
execfile(os.path.join(ETC_DIR, 'settings.py'))
exec(open(os.path.join(ETC_DIR, 'settings.py')).read())
# run additional settings snippets
execfile('/usr/lib/hobo/debian_config_settings_d.py')
exec(open('/usr/lib/hobo/debian_config_settings_d.py').read())

3
debian/settings.py vendored
View File

@ -9,7 +9,8 @@
# WARNING! Quick-start development settings unsuitable for production!
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# This file is sourced by "execfile" from /usr/lib/welco/debian_config.py
# This file is sourced by "exec(open(...).read())" from
# /usr/lib/welco/debian_config.py
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

View File

@ -220,4 +220,4 @@ REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = ['rest_framework.authenticati
local_settings_file = os.environ.get('WELCO_SETTINGS_FILE',
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
if os.path.exists(local_settings_file):
execfile(local_settings_file)
exec(open(local_settings_file).read())