From 02a42888273bd786d4ad56ddce92f175bd847ac3 Mon Sep 17 00:00:00 2001 From: Cao Xuan Hoang Date: Mon, 6 Feb 2017 11:21:15 +0700 Subject: [PATCH] Clean imports in code This patch set modifies lines which are importing objects instead of modules. As per openstack import guide lines, user should import modules in a file not objects. http://docs.openstack.org/developer/hacking/#imports Change-Id: Ibfaf35be7506db820bea8e41a7fc8fcaf20fe08a --- disaster_recovery/api/rest/rest_api.py | 12 ++++++------ disaster_recovery/backups/workflows/restore.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/disaster_recovery/api/rest/rest_api.py b/disaster_recovery/api/rest/rest_api.py index 833e9dd..49bfe9f 100644 --- a/disaster_recovery/api/rest/rest_api.py +++ b/disaster_recovery/api/rest/rest_api.py @@ -15,11 +15,11 @@ import functools import json -from django.http import HttpResponse +from django import http from django.views import generic from openstack_dashboard.api.rest import utils as rest_utils -from openstack_dashboard.api.rest.utils import JSONResponse +from openstack_dashboard.api.rest import utils import disaster_recovery.api.api as freezer_api @@ -30,7 +30,7 @@ def prevent_json_hijacking(function): @functools.wraps(function) def wrapper(*args, **kwargs): response = function(*args, **kwargs) - if isinstance(response, JSONResponse) and response.content: + if isinstance(response, utils.JSONResponse) and response.content: response.content = ")]}',\n" + response.content return response @@ -49,7 +49,7 @@ class Clients(generic.View): # we need to resort to getting a very high number. clients = freezer_api.Client(request).list(json=True) clients = json.dumps(clients) - return HttpResponse(clients, content_type="application/json") + return http.HttpResponse(clients, content_type="application/json") class ActionList(generic.View): @@ -60,7 +60,7 @@ class ActionList(generic.View): actions = freezer_api.Action(request).list(json=True) actions = json.dumps(actions) - return HttpResponse(actions, content_type="application/json") + return http.HttpResponse(actions, content_type="application/json") class Actions(generic.View): @@ -90,4 +90,4 @@ class Actions(generic.View): 'selected': selected_actions} actions = json.dumps(actions) - return HttpResponse(actions, content_type="application/json") + return http.HttpResponse(actions, content_type="application/json") diff --git a/disaster_recovery/backups/workflows/restore.py b/disaster_recovery/backups/workflows/restore.py index 5f70e5a..51b318f 100644 --- a/disaster_recovery/backups/workflows/restore.py +++ b/disaster_recovery/backups/workflows/restore.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from django.core.exceptions import ValidationError +from django.core import exceptions as d_exceptions from django.utils.translation import ugettext_lazy as _ from horizon import exceptions @@ -32,7 +32,7 @@ class DestinationAction(workflows.MembershipAction): if 'client' in self.request.POST: self.cleaned_data['client'] = self.request.POST['client'] else: - raise ValidationError(_('Client is required')) + raise d_exceptions.ValidationError(_('Client is required')) return self.cleaned_data