setup_environ and execute_from_manager are deprecated starting on Django 1.4, as described on release notes document:
https://docs.djangoproject.com/en/dev/releases/1.4/ Also the recommended way to setup the django settings is via an environment variable. Signed-off-by: Cleber Rosa <[email protected]> --- frontend/autotest-manage-rpc-server | 22 ++++++++++------------ frontend/manage.py | 19 +++++++++++-------- frontend/setup_django_environment.py | 18 ++++++------------ 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/frontend/autotest-manage-rpc-server b/frontend/autotest-manage-rpc-server index 3c6c678..b963af2 100755 --- a/frontend/autotest-manage-rpc-server +++ b/frontend/autotest-manage-rpc-server @@ -1,20 +1,18 @@ #!/usr/bin/env python + + +import os +import sys + +from django.core.management import execute_from_command_line + + try: import autotest.common as common except ImportError: import common -from django.core.management import execute_manager - -try: - try: - from autotest.frontend import settings - except ImportError: - import settings -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) if __name__ == "__main__": - execute_manager(settings) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "autotest.frontend.settings") + execute_from_command_line(sys.argv) diff --git a/frontend/manage.py b/frontend/manage.py index d6acda5..b963af2 100755 --- a/frontend/manage.py +++ b/frontend/manage.py @@ -1,15 +1,18 @@ #!/usr/bin/env python + + +import os +import sys + +from django.core.management import execute_from_command_line + + try: import autotest.common as common except ImportError: import common -from django.core.management import execute_manager -try: - import settings # Assumed to be in the same directory. -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) + if __name__ == "__main__": - execute_manager(settings) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "autotest.frontend.settings") + execute_from_command_line(sys.argv) diff --git a/frontend/setup_django_environment.py b/frontend/setup_django_environment.py index e0ab015..4fb72dd 100644 --- a/frontend/setup_django_environment.py +++ b/frontend/setup_django_environment.py @@ -1,13 +1,7 @@ -from django.core import management -try: - import autotest.common as common -except ImportError: - import common -from autotest.frontend import settings +import os -management.setup_environ(settings) - -def enable_autocommit(): - from django.db import connection - connection.cursor() # ensure a connection is open - connection.connection.autocommit(True) +# +# Django >= 1.4 makes the setup of a particular setting this simple. And yes, +# this is the recommended way to do it. +# +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "autotest.frontend.settings") -- 1.7.11.7 _______________________________________________ Autotest-kernel mailing list [email protected] https://www.redhat.com/mailman/listinfo/autotest-kernel
