From 8d1ec570458a7bb5171958e616b7d1c570147bf5 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 15 Jan 2016 17:42:47 +0800 Subject: [PATCH] [Django 1.9] Stop using django.utils.importlib Horizon still uses django.utils.importlib which is removed from Django 1.9. We should use: from importlib import import_module instead of: from django.utils.importlib import import_module Change-Id: I422e14546468cb9c5627e746023948aab107a338 Closes-Bug: #1534522 Partially-Implements: blueprint drop-dj17 Co-Authored-By: Rob Cresswell --- horizon/base.py | 2 +- horizon/management/commands/startdash.py | 2 +- horizon/management/commands/startpanel.py | 2 +- horizon/test/tests/base.py | 2 +- horizon/workflows/base.py | 2 +- .../contrib/developer/theme_preview/tests.py | 2 +- openstack_dashboard/test/helpers.py | 7 ++++--- openstack_dashboard/utils/settings.py | 7 +++---- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/horizon/base.py b/horizon/base.py index 04123afdb..3295c2391 100644 --- a/horizon/base.py +++ b/horizon/base.py @@ -35,9 +35,9 @@ from django.core.urlresolvers import reverse from django.utils.encoding import python_2_unicode_compatible from django.utils.functional import empty from django.utils.functional import SimpleLazyObject # noqa -from django.utils.importlib import import_module # noqa from django.utils.module_loading import module_has_submodule # noqa from django.utils.translation import ugettext_lazy as _ +from importlib import import_module import six from horizon import conf diff --git a/horizon/management/commands/startdash.py b/horizon/management/commands/startdash.py index af6c00256..4cc82af57 100644 --- a/horizon/management/commands/startdash.py +++ b/horizon/management/commands/startdash.py @@ -16,7 +16,7 @@ import os from django.core.management.base import CommandError # noqa from django.core.management.templates import TemplateCommand # noqa -from django.utils.importlib import import_module # noqa +from importlib import import_module import horizon diff --git a/horizon/management/commands/startpanel.py b/horizon/management/commands/startpanel.py index 3185a3fa2..a2ebe915e 100644 --- a/horizon/management/commands/startpanel.py +++ b/horizon/management/commands/startpanel.py @@ -16,7 +16,7 @@ import os from django.core.management.base import CommandError # noqa from django.core.management.templates import TemplateCommand # noqa -from django.utils.importlib import import_module # noqa +from importlib import import_module import horizon diff --git a/horizon/test/tests/base.py b/horizon/test/tests/base.py index 2ce463753..5c64e8deb 100644 --- a/horizon/test/tests/base.py +++ b/horizon/test/tests/base.py @@ -21,7 +21,7 @@ from django.conf import settings from django.contrib.auth.models import User # noqa from django.core.exceptions import ImproperlyConfigured # noqa from django.core import urlresolvers -from django.utils.importlib import import_module # noqa +from importlib import import_module from six import moves import six diff --git a/horizon/workflows/base.py b/horizon/workflows/base.py index 74a60262f..2ec95994e 100644 --- a/horizon/workflows/base.py +++ b/horizon/workflows/base.py @@ -24,8 +24,8 @@ from django.template.defaultfilters import linebreaks # noqa from django.template.defaultfilters import safe # noqa from django.template.defaultfilters import slugify # noqa from django.utils.encoding import force_text -from django.utils.importlib import import_module # noqa from django.utils.translation import ugettext_lazy as _ +from importlib import import_module import six from horizon import base diff --git a/openstack_dashboard/contrib/developer/theme_preview/tests.py b/openstack_dashboard/contrib/developer/theme_preview/tests.py index 753ec4bc6..373bc7ce0 100644 --- a/openstack_dashboard/contrib/developer/theme_preview/tests.py +++ b/openstack_dashboard/contrib/developer/theme_preview/tests.py @@ -16,7 +16,7 @@ from django.conf import settings from django.core import urlresolvers from django.core.urlresolvers import reverse -from django.utils.importlib import import_module # noqa +from importlib import import_module from six import moves from horizon import base diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py index 5dfa29521..6f1560e4f 100644 --- a/openstack_dashboard/test/helpers.py +++ b/openstack_dashboard/test/helpers.py @@ -22,8 +22,6 @@ from functools import wraps # noqa import os import unittest -from ceilometerclient.v2 import client as ceilometer_client -from cinderclient import client as cinder_client import django from django.conf import settings from django.contrib.messages.storage import default_storage # noqa @@ -31,10 +29,13 @@ from django.core.handlers import wsgi from django.core import urlresolvers from django.test.client import RequestFactory # noqa from django.test import utils as django_test_utils -from django.utils.importlib import import_module # noqa + +from ceilometerclient.v2 import client as ceilometer_client +from cinderclient import client as cinder_client import glanceclient from heatclient import client as heat_client import httplib2 +from importlib import import_module from keystoneclient.v2_0 import client as keystone_client import mock from mox3 import mox diff --git a/openstack_dashboard/utils/settings.py b/openstack_dashboard/utils/settings.py index 6a6d16dc7..8bf999055 100644 --- a/openstack_dashboard/utils/settings.py +++ b/openstack_dashboard/utils/settings.py @@ -11,11 +11,10 @@ # under the License. import collections +from importlib import import_module import logging import os import pkgutil - -from django.utils import importlib import six from horizon.utils import file_discovery as fd @@ -27,7 +26,7 @@ def import_submodules(module): for loader, name, ispkg in pkgutil.iter_modules(module.__path__, module.__name__ + '.'): try: - submodule = importlib.import_module(name) + submodule = import_module(name) except ImportError as e: # FIXME: Make the errors non-fatal (do we want that?). logging.warning("Error importing %s" % name) @@ -120,7 +119,7 @@ def update_dashboards(modules, horizon_config, installed_apps): if config.get('AUTO_DISCOVER_STATIC_FILES', False): for _app in _apps: - module = importlib.import_module(_app) + module = import_module(_app) base_path = os.path.join(module.__path__[0], 'static/') fd.populate_horizon_config(horizon_config, base_path)