Merge "Remove six usage"

This commit is contained in:
Zuul 2020-02-06 01:09:11 +00:00 committed by Gerrit Code Review
commit e03bad61e9
16 changed files with 102 additions and 145 deletions

View File

@ -15,7 +15,6 @@
from django.urls import reverse from django.urls import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import mock import mock
import six
from openstack_auth import policy from openstack_auth import policy
from openstack_dashboard import api as dash_api from openstack_dashboard import api as dash_api
@ -150,7 +149,7 @@ class DatabasesBackupsTests(test.TestCase):
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)
self.mock_backup_get.assert_called_once_with( self.mock_backup_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str)) test.IsHttpRequest(), test.IsA(str))
self.assertTemplateUsed(res, self.assertTemplateUsed(res,
@ -162,7 +161,7 @@ class DatabasesBackupsTests(test.TestCase):
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)
self.mock_backup_get.assert_called_once_with( self.mock_backup_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.assertRedirectsNoFollow(res, INDEX_URL) self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_mocks({api.trove: ('backup_get', 'instance_get')}) @test.create_mocks({api.trove: ('backup_get', 'instance_get')})
@ -177,7 +176,7 @@ class DatabasesBackupsTests(test.TestCase):
args=[incr_backup.id]) args=[incr_backup.id])
res = self.client.get(url) res = self.client.get(url)
self.assertEqual( self.assertEqual(
[mock.call(test.IsHttpRequest(), test.IsA(six.text_type)), [mock.call(test.IsHttpRequest(), test.IsA(str)),
mock.call(test.IsHttpRequest(), incr_backup.parent_id)], mock.call(test.IsHttpRequest(), incr_backup.parent_id)],
self.mock_backup_get.call_args_list) self.mock_backup_get.call_args_list)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
@ -216,13 +215,12 @@ class DatabasesBackupsTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_check, 4, mock.call((), test.IsHttpRequest())) self.mock_check, 4, mock.call((), test.IsHttpRequest()))
self.mock_backup_get.assert_called_once_with( self.mock_backup_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest()) self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_configuration_list.assert_called_once_with( self.mock_configuration_list.assert_called_once_with(
test.IsHttpRequest()) test.IsHttpRequest())
self.mock_datastore_flavors.assert_called_once_with( self.mock_datastore_flavors.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.string_types), test.IsHttpRequest(), test.IsA(str), test.IsA(str))
test.IsA(six.string_types))
self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest()) self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest())
self.mock_datastore_version_list.assert_called_once_with( self.mock_datastore_version_list.assert_called_once_with(
test.IsHttpRequest(), backup.datastore['type']) test.IsHttpRequest(), backup.datastore['type'])

View File

@ -20,8 +20,6 @@ from django.urls import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.decorators.debug import sensitive_variables # noqa from django.views.decorators.debug import sensitive_variables # noqa
import six
from horizon import exceptions from horizon import exceptions
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
@ -376,8 +374,7 @@ class LaunchForm(forms.SelfHandlingForm):
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:database_clusters:index") redirect = reverse("horizon:project:database_clusters:index")
exceptions.handle(request, exceptions.handle(request,
_('Unable to launch cluster. %s') % _('Unable to launch cluster. %s') % e,
six.text_type(e),
redirect=redirect) redirect=redirect)
@ -479,8 +476,7 @@ class ClusterAddInstanceForm(forms.SelfHandlingForm):
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:database_clusters:index") redirect = reverse("horizon:project:database_clusters:index")
exceptions.handle(request, exceptions.handle(request,
_('Unable to grow cluster. %s') % _('Unable to grow cluster. %s') % e,
six.text_type(e),
redirect=redirect) redirect=redirect)
return True return True
@ -503,6 +499,6 @@ class ResetPasswordForm(forms.SelfHandlingForm):
'cluster "%s"') % cluster_id) 'cluster "%s"') % cluster_id)
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:database_clusters:index") redirect = reverse("horizon:project:database_clusters:index")
exceptions.handle(request, _('Unable to reset password. %s') % exceptions.handle(request, _('Unable to reset password. %s') % e,
six.text_type(e), redirect=redirect) redirect=redirect)
return True return True

View File

@ -20,8 +20,6 @@ from django import urls
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy from django.utils.translation import ungettext_lazy
import six
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
from horizon.templatetags import sizeformat from horizon.templatetags import sizeformat
@ -280,10 +278,10 @@ class ClusterShrinkAction(tables.BatchAction):
except Exception as ex: except Exception as ex:
LOG.error('Action %(action)s failed with %(ex)s for %(data)s' % LOG.error('Action %(action)s failed with %(ex)s for %(data)s' %
{'action': self._get_action_name(past=True).lower(), {'action': self._get_action_name(past=True).lower(),
'ex': six.text_type(ex), 'ex': ex,
'data': display_str}) 'data': display_str})
msg = _('Unable to remove instances from cluster: %s') msg = _('Unable to remove instances from cluster: %s')
messages.error(request, msg % six.text_type(ex)) messages.error(request, msg % ex)
return shortcuts.redirect(self.get_success_url(request)) return shortcuts.redirect(self.get_success_url(request))
@ -415,10 +413,10 @@ class ClusterGrowAction(tables.Action):
messages.success(request, msg) messages.success(request, msg)
except Exception as ex: except Exception as ex:
LOG.error('Action grow cluster failed with %(ex)s for %(data)s' % LOG.error('Action grow cluster failed with %(ex)s for %(data)s' %
{'ex': six.text_type(ex), {'ex': ex,
'data': display_str}) 'data': display_str})
msg = _('Unable to grow cluster: %s') msg = _('Unable to grow cluster: %s')
messages.error(request, msg % six.text_type(ex)) messages.error(request, msg % ex)
finally: finally:
cluster_manager.delete(cluster_id) cluster_manager.delete(cluster_id)

View File

@ -23,8 +23,6 @@ from django.urls import reverse
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions from horizon import exceptions
from horizon import forms as horizon_forms from horizon import forms as horizon_forms
from horizon import tables as horizon_tables from horizon import tables as horizon_tables
@ -58,7 +56,7 @@ class IndexView(horizon_tables.DataTableView):
flavors = [] flavors = []
msg = _('Unable to retrieve database size information.') msg = _('Unable to retrieve database size information.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return OrderedDict((six.text_type(flavor.id), flavor) return OrderedDict((str(flavor.id), flavor)
for flavor in flavors) for flavor in flavors)
def _extra_data(self, cluster): def _extra_data(self, cluster):

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import builtins
from django.core import cache from django.core import cache
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@ -19,7 +20,6 @@ from django.utils.translation import ugettext_lazy as _
from trove_dashboard import api from trove_dashboard import api
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from six.moves import builtins
def get(request, configuration_group_id): def get(request, configuration_group_id):

View File

@ -15,8 +15,6 @@
from django.urls import reverse from django.urls import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions from horizon import exceptions
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
@ -108,8 +106,7 @@ class CreateConfigurationForm(forms.SelfHandlingForm):
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:database_configurations:index") redirect = reverse("horizon:project:database_configurations:index")
exceptions.handle(request, _('Unable to create configuration ' exceptions.handle(request, _('Unable to create configuration '
'group. %s') 'group. %s') % e, redirect=redirect)
% six.text_type(e), redirect=redirect)
return True return True
@ -186,6 +183,7 @@ class AddParameterForm(forms.SelfHandlingForm):
messages.success(request, _('Successfully added parameter')) messages.success(request, _('Successfully added parameter'))
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:database_configurations:index") redirect = reverse("horizon:project:database_configurations:index")
exceptions.handle(request, _('Unable to add new parameter: %s') exceptions.handle(request,
% six.text_type(e), redirect=redirect) _('Unable to add new parameter: %s') % e,
redirect=redirect)
return True return True

View File

@ -17,8 +17,6 @@ from django import urls
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy from django.utils.translation import ungettext_lazy
import six
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
@ -139,7 +137,7 @@ class DiscardChanges(tables.Action):
except Exception as ex: except Exception as ex:
messages.error( messages.error(
request, request,
_('Error resetting parameters: %s') % six.text_type(ex)) _('Error resetting parameters: %s') % ex)
return shortcuts.redirect(request.build_absolute_uri()) return shortcuts.redirect(request.build_absolute_uri())

View File

@ -14,7 +14,6 @@
import logging import logging
import mock import mock
import six
import django import django
from django.conf import settings from django.conf import settings
@ -338,12 +337,10 @@ class DatabaseConfigurationsTests(test.TestCase):
post) post)
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_get, 2, self.mock_get, 2,
mock.call(test.IsHttpRequest(), test.IsA(six.string_types))) mock.call(test.IsHttpRequest(), test.IsA(str)))
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_configuration_parameters_list, 2, self.mock_configuration_parameters_list, 2,
mock.call(test.IsHttpRequest(), mock.call(test.IsHttpRequest(), test.IsA(str), test.IsA(str)))
test.IsA(six.string_types),
test.IsA(six.string_types)))
self.assertFormError(res, "form", 'value', self.assertFormError(res, "form", 'value',
['Value must be a number.']) ['Value must be a number.'])
finally: finally:

View File

@ -16,8 +16,6 @@ from django.forms import ValidationError # noqa
from django.urls import reverse from django.urls import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions from horizon import exceptions
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
@ -48,8 +46,8 @@ class CreateDatabaseForm(forms.SelfHandlingForm):
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:databases:detail", redirect = reverse("horizon:project:databases:detail",
args=(instance,)) args=(instance,))
exceptions.handle(request, _('Unable to create database. %s') % exceptions.handle(request, _('Unable to create database. %s') % e,
six.text_type(e), redirect=redirect) redirect=redirect)
return True return True
@ -89,8 +87,8 @@ class ResizeVolumeForm(forms.SelfHandlingForm):
messages.success(request, _('Resizing volume "%s"') % instance) messages.success(request, _('Resizing volume "%s"') % instance)
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:databases:index") redirect = reverse("horizon:project:databases:index")
exceptions.handle(request, _('Unable to resize volume. %s') % exceptions.handle(request, _('Unable to resize volume. %s') % e,
six.text_type(e), redirect=redirect) redirect=redirect)
return True return True
@ -127,8 +125,8 @@ class ResizeInstanceForm(forms.SelfHandlingForm):
messages.success(request, _('Resizing instance "%s"') % instance) messages.success(request, _('Resizing instance "%s"') % instance)
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:databases:index") redirect = reverse("horizon:project:databases:index")
exceptions.handle(request, _('Unable to resize instance. %s') % exceptions.handle(request, _('Unable to resize instance. %s') % e,
six.text_type(e), redirect=redirect) redirect=redirect)
return True return True
@ -148,7 +146,7 @@ class PromoteToReplicaSourceForm(forms.SelfHandlingForm):
exceptions.handle( exceptions.handle(
request, request,
_('Unable to promote replica as the new replica source. "%s"') _('Unable to promote replica as the new replica source. "%s"')
% six.text_type(e), redirect=redirect) % e, redirect=redirect)
return True return True
@ -183,8 +181,8 @@ class CreateUserForm(forms.SelfHandlingForm):
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:databases:detail", redirect = reverse("horizon:project:databases:detail",
args=(instance,)) args=(instance,))
exceptions.handle(request, _('Unable to create user. %s') % exceptions.handle(request, _('Unable to create user. %s') % e,
six.text_type(e), redirect=redirect) redirect=redirect)
return True return True
def _get_databases(self, data): def _get_databases(self, data):
@ -232,8 +230,8 @@ class EditUserForm(forms.SelfHandlingForm):
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:databases:detail", redirect = reverse("horizon:project:databases:detail",
args=(instance,)) args=(instance,))
exceptions.handle(request, _('Unable to update user. %s') % exceptions.handle(request, _('Unable to update user. %s') % e,
six.text_type(e), redirect=redirect) redirect=redirect)
return True return True
def clean(self): def clean(self):
@ -280,6 +278,6 @@ class AttachConfigurationForm(forms.SelfHandlingForm):
except Exception as e: except Exception as e:
redirect = reverse("horizon:project:databases:index") redirect = reverse("horizon:project:databases:index")
exceptions.handle(request, _('Unable to attach configuration ' exceptions.handle(request, _('Unable to attach configuration '
'group. %s') 'group. %s') % e,
% six.text_type(e), redirect=redirect) redirect=redirect)
return True return True

View File

@ -18,7 +18,6 @@ from django import http
from django.urls import reverse from django.urls import reverse
import mock import mock
import six
from trove_dashboard import api from trove_dashboard import api
from trove_dashboard.test import helpers as test from trove_dashboard.test import helpers as test
@ -45,7 +44,7 @@ class LogsTests(test.TestCase):
url = detail_url + '?tab=instance_details__logs_tab' url = detail_url + '?tab=instance_details__logs_tab'
res = self.client.get(url) res = self.client.get(url)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -83,7 +82,7 @@ class LogsTests(test.TestCase):
try: try:
res = self.client.get(url) res = self.client.get(url)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -118,7 +117,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -146,7 +145,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -174,7 +173,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -202,7 +201,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -230,7 +229,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -258,7 +257,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -286,7 +285,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -314,7 +313,7 @@ class LogsTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_log_list.assert_called_once_with( self.mock_log_list.assert_called_once_with(
test.IsHttpRequest(), database_id) test.IsHttpRequest(), database_id)
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
@ -346,7 +345,7 @@ class LogsTests(test.TestCase):
auth_version="3") auth_version="3")
self.mock_log_tail.assert_called_once_with( self.mock_log_tail.assert_called_once_with(
test.IsHttpRequest(), test.IsHttpRequest(),
test.IsA(six.string_types), test.IsA(str),
'guest.log', 'guest.log',
False, False,
LINES, LINES,
@ -377,7 +376,7 @@ class LogsTests(test.TestCase):
auth_version="3") auth_version="3")
self.mock_log_tail.assert_called_once_with( self.mock_log_tail.assert_called_once_with(
test.IsHttpRequest(), test.IsHttpRequest(),
test.IsA(six.string_types), test.IsA(str),
'guest.log', 'guest.log',
False, False,
LINES, LINES,

View File

@ -17,8 +17,6 @@ from django import shortcuts
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views import generic from django.views import generic
import six
from horizon import exceptions from horizon import exceptions
from horizon import messages from horizon import messages
@ -65,8 +63,7 @@ def get_contents(request, instance_id, filename, publish, lines):
for log_part in log_generator(): for log_part in log_generator():
data += log_part data += log_part
except Exception as e: except Exception as e:
data = _('Unable to load {0} log\n{1}').format(filename, data = _('Unable to load {0} log\n{1}').format(filename, e)
six.text_type(e))
return data return data

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from urllib import parse as urlparse
from django.conf import settings from django.conf import settings
from django.template import defaultfilters as d_filters from django.template import defaultfilters as d_filters
from django import urls from django import urls
@ -20,9 +22,6 @@ from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy from django.utils.translation import ungettext_lazy
import six
import six.moves.urllib.parse as urlparse
from horizon import exceptions from horizon import exceptions
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
@ -511,8 +510,7 @@ class DisableRootAction(tables.Action):
messages.success(request, _("Successfully disabled root access.")) messages.success(request, _("Successfully disabled root access."))
except Exception as e: except Exception as e:
messages.warning(request, messages.warning(request,
_("Cannot disable root access: %s") % _("Cannot disable root access: %s") % e)
six.text_type(e))
class ManageRoot(tables.LinkAction): class ManageRoot(tables.LinkAction):

View File

@ -15,8 +15,6 @@
from django import template from django import template
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions from horizon import exceptions
from horizon import tabs from horizon import tabs
from oslo_log import log as logging from oslo_log import log as logging
@ -180,7 +178,7 @@ class LogsTab(tabs.TableTab):
return logs return logs
except Exception as e: except Exception as e:
LOG.exception( LOG.exception(
_('Unable to retrieve list of logs.\n%s') % six.text_type(e)) _('Unable to retrieve list of logs.\n%s') % e)
logs = [] logs = []
return logs return logs

View File

@ -21,7 +21,6 @@ from django.urls import reverse
import unittest import unittest
import mock import mock
import six
from horizon import exceptions from horizon import exceptions
from openstack_auth import policy from openstack_auth import policy
@ -158,8 +157,8 @@ class DatabaseTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_datastore_flavors, 20, self.mock_datastore_flavors, 20,
mock.call(test.IsHttpRequest(), mock.call(test.IsHttpRequest(),
test.IsA(six.string_types), test.IsA(str),
test.IsA(six.string_types))) test.IsA(str)))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest()) self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_configuration_list.assert_called_once_with( self.mock_configuration_list.assert_called_once_with(
test.IsHttpRequest()) test.IsHttpRequest())
@ -264,8 +263,8 @@ class DatabaseTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_datastore_flavors, 20, self.mock_datastore_flavors, 20,
mock.call(test.IsHttpRequest(), mock.call(test.IsHttpRequest(),
test.IsA(six.string_types), test.IsA(str),
test.IsA(six.string_types))) test.IsA(str)))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest()) self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_instance_list.assert_called_once_with(test.IsHttpRequest()) self.mock_instance_list.assert_called_once_with(test.IsHttpRequest())
self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest()) self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest())
@ -283,9 +282,9 @@ class DatabaseTests(test.TestCase):
test.IsHttpRequest()) test.IsHttpRequest())
self.mock_instance_create.assert_called_once_with( self.mock_instance_create.assert_called_once_with(
test.IsHttpRequest(), test.IsHttpRequest(),
test.IsA(six.text_type), test.IsA(str),
test.IsA(int), test.IsA(int),
test.IsA(six.text_type), test.IsA(str),
databases=None, databases=None,
datastore=datastore, datastore=datastore,
datastore_version=datastore_version, datastore_version=datastore_version,
@ -297,7 +296,7 @@ class DatabaseTests(test.TestCase):
replica_count=None, replica_count=None,
volume_type=None, volume_type=None,
locality=None, locality=None,
availability_zone=test.IsA(six.text_type)) availability_zone=test.IsA(str))
self.assertRedirectsNoFollow(res, INDEX_URL) self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_mocks({ @test.create_mocks({
@ -354,8 +353,8 @@ class DatabaseTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_datastore_flavors, 20, self.mock_datastore_flavors, 20,
mock.call(test.IsHttpRequest(), mock.call(test.IsHttpRequest(),
test.IsA(six.string_types), test.IsA(str),
test.IsA(six.string_types))) test.IsA(str)))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest()) self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_instance_list.assert_called_once_with(test.IsHttpRequest()) self.mock_instance_list.assert_called_once_with(test.IsHttpRequest())
self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest()) self.mock_datastore_list.assert_called_once_with(test.IsHttpRequest())
@ -373,9 +372,9 @@ class DatabaseTests(test.TestCase):
test.IsHttpRequest()) test.IsHttpRequest())
self.mock_instance_create.assert_called_once_with( self.mock_instance_create.assert_called_once_with(
test.IsHttpRequest(), test.IsHttpRequest(),
test.IsA(six.text_type), test.IsA(str),
test.IsA(int), test.IsA(int),
test.IsA(six.text_type), test.IsA(str),
databases=None, databases=None,
datastore=datastore, datastore=datastore,
datastore_version=datastore_version, datastore_version=datastore_version,
@ -387,7 +386,7 @@ class DatabaseTests(test.TestCase):
replica_count=None, replica_count=None,
volume_type=None, volume_type=None,
locality=None, locality=None,
availability_zone=test.IsA(six.text_type)) availability_zone=test.IsA(str))
self.assertRedirectsNoFollow(res, INDEX_URL) self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_mocks({ @test.create_mocks({
@ -409,7 +408,7 @@ class DatabaseTests(test.TestCase):
try: try:
res = self.client.get(DETAILS_URL) res = self.client.get(DETAILS_URL)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str)) test.IsHttpRequest(), test.IsA(str))
self.mock_root_show.assert_called_once_with( self.mock_root_show.assert_called_once_with(
@ -521,7 +520,7 @@ class DatabaseTests(test.TestCase):
args=['id']) args=['id'])
res = self.client.get(url) res = self.client.get(url)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_root_show, 2, self.mock_root_show, 2,
mock.call(test.IsHttpRequest(), database.id)) mock.call(test.IsHttpRequest(), database.id))
@ -539,7 +538,7 @@ class DatabaseTests(test.TestCase):
args=['id']) args=['id'])
res = self.client.get(url) res = self.client.get(url)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_root_show.assert_called_once_with( self.mock_root_show.assert_called_once_with(
test.IsHttpRequest(), u'id') test.IsHttpRequest(), u'id')
self.assertRedirectsNoFollow(res, DETAILS_URL) self.assertRedirectsNoFollow(res, DETAILS_URL)
@ -667,7 +666,7 @@ class DatabaseTests(test.TestCase):
form_data = {'action': action_string} form_data = {'action': action_string}
res = self.client.post(url, form_data) res = self.client.post(url, form_data)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_flavor_get.assert_called_once_with( self.mock_flavor_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str)) test.IsHttpRequest(), test.IsA(str))
self.mock_users_list.assert_called_once_with( self.mock_users_list.assert_called_once_with(
@ -752,11 +751,11 @@ class DatabaseTests(test.TestCase):
res = self.client.post(url, post) res = self.client.post(url, post)
self.mock_user_update_attributes.assert_called_once_with( self.mock_user_update_attributes.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type), test.IsHttpRequest(), test.IsA(str),
test.IsA(six.text_type), host=test.IsA(six.text_type), test.IsA(str), host=test.IsA(str),
new_name=test.IsA(six.text_type), new_name=test.IsA(str),
new_password=test.IsA(six.text_type), new_password=test.IsA(str),
new_host=test.IsA(six.text_type)) new_host=test.IsA(str))
self.assertNoFormErrors(res) self.assertNoFormErrors(res)
self.assertMessageCount(success=1) self.assertMessageCount(success=1)
@ -778,11 +777,11 @@ class DatabaseTests(test.TestCase):
res = self.client.post(url, post) res = self.client.post(url, post)
self.mock_user_update_attributes.assert_called_once_with( self.mock_user_update_attributes.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type), test.IsHttpRequest(), test.IsA(str),
test.IsA(six.text_type), host=test.IsA(six.text_type), test.IsA(str), host=test.IsA(str),
new_name=test.IsA(six.text_type), new_name=test.IsA(str),
new_password=test.IsA(six.text_type), new_password=test.IsA(str),
new_host=test.IsA(six.text_type)) new_host=test.IsA(str))
self.assertEqual(res.status_code, 302) self.assertEqual(res.status_code, 302)
def test_edit_user_no_values(self): def test_edit_user_no_values(self):
@ -810,10 +809,10 @@ class DatabaseTests(test.TestCase):
args=['id', 'name', 'host']) args=['id', 'name', 'host'])
res = self.client.get(url) res = self.client.get(url)
self.mock_database_list.assert_called_once_with( self.mock_database_list.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_user_show_access.assert_called_once_with( self.mock_user_show_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type), test.IsHttpRequest(), test.IsA(str),
test.IsA(six.text_type), host=test.IsA(six.text_type)) test.IsA(str), host=test.IsA(str))
self.assertTemplateUsed( self.assertTemplateUsed(
res, 'project/databases/access_detail.html') res, 'project/databases/access_detail.html')
@ -826,10 +825,10 @@ class DatabaseTests(test.TestCase):
args=['id', 'name', 'host']) args=['id', 'name', 'host'])
res = self.client.get(url) res = self.client.get(url)
self.mock_database_list.assert_called_once_with( self.mock_database_list.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_user_show_access.assert_called_once_with( self.mock_user_show_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type), test.IsHttpRequest(), test.IsA(str),
test.IsA(six.text_type), host=test.IsA(six.text_type)) test.IsA(str), host=test.IsA(str))
self.assertRedirectsNoFollow(res, DETAILS_URL) self.assertRedirectsNoFollow(res, DETAILS_URL)
@test.create_mocks({api.trove: ('user_grant_access',)}) @test.create_mocks({api.trove: ('user_grant_access',)})
@ -850,7 +849,7 @@ class DatabaseTests(test.TestCase):
self.mock_user_grant_access.assert_called_once_with( self.mock_user_grant_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str), test.IsA(str), test.IsHttpRequest(), test.IsA(str), test.IsA(str),
[test.IsA(six.text_type)], host=test.IsA(str)) [test.IsA(str)], host=test.IsA(str))
handled_url = handled['location'] handled_url = handled['location']
self.assertEqual(handled_url, url) self.assertEqual(handled_url, url)
@ -874,7 +873,7 @@ class DatabaseTests(test.TestCase):
self.mock_user_grant_access.assert_called_once_with( self.mock_user_grant_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str), test.IsA(str), test.IsHttpRequest(), test.IsA(str), test.IsA(str),
[test.IsA(six.text_type)], host=test.IsA(str)) [test.IsA(str)], host=test.IsA(str))
handled_url = handled['location'] handled_url = handled['location']
self.assertEqual(handled_url, url) self.assertEqual(handled_url, url)
@ -896,7 +895,7 @@ class DatabaseTests(test.TestCase):
self.mock_user_revoke_access.assert_called_once_with( self.mock_user_revoke_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str), test.IsA(str), test.IsHttpRequest(), test.IsA(str), test.IsA(str),
test.IsA(six.text_type), host=test.IsA(str)) test.IsA(str), host=test.IsA(str))
handled_url = handled['location'] handled_url = handled['location']
self.assertEqual(handled_url, url) self.assertEqual(handled_url, url)
@ -920,7 +919,7 @@ class DatabaseTests(test.TestCase):
self.mock_user_revoke_access.assert_called_once_with( self.mock_user_revoke_access.assert_called_once_with(
test.IsHttpRequest(), test.IsA(str), test.IsA(str), test.IsHttpRequest(), test.IsA(str), test.IsA(str),
test.IsA(six.text_type), host=test.IsA(str)) test.IsA(str), host=test.IsA(str))
handled_url = handled['location'] handled_url = handled['location']
self.assertEqual(handled_url, url) self.assertEqual(handled_url, url)
@ -946,7 +945,7 @@ class DatabaseTests(test.TestCase):
} }
res = self.client.post(url, post) res = self.client.post(url, post)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_instance_resize_volume.assert_called_once_with( self.mock_instance_resize_volume.assert_called_once_with(
test.IsHttpRequest(), database_id, test.IsA(int)) test.IsHttpRequest(), database_id, test.IsA(int))
self.assertNoFormErrors(res) self.assertNoFormErrors(res)
@ -970,7 +969,7 @@ class DatabaseTests(test.TestCase):
} }
res = self.client.post(url, post) res = self.client.post(url, post)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.assertContains( self.assertContains(
res, "New size for volume must be greater than current size.") res, "New size for volume must be greater than current size.")
@ -1088,8 +1087,8 @@ class DatabaseTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_datastore_flavors, 20, self.mock_datastore_flavors, 20,
mock.call(test.IsHttpRequest(), mock.call(test.IsHttpRequest(),
test.IsA(six.string_types), test.IsA(str),
test.IsA(six.string_types))) test.IsA(str)))
self.mock_backup_list.assert_called_once_with(test.IsHttpRequest()) self.mock_backup_list.assert_called_once_with(test.IsHttpRequest())
self.mock_instance_list_all.assert_called_once_with( self.mock_instance_list_all.assert_called_once_with(
test.IsHttpRequest()) test.IsHttpRequest())
@ -1107,12 +1106,12 @@ class DatabaseTests(test.TestCase):
self.mock_availability_zone_list.assert_called_once_with( self.mock_availability_zone_list.assert_called_once_with(
test.IsHttpRequest()) test.IsHttpRequest())
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_instance_create.assert_called_once_with( self.mock_instance_create.assert_called_once_with(
test.IsHttpRequest(), test.IsHttpRequest(),
test.IsA(six.text_type), test.IsA(str),
test.IsA(int), test.IsA(int),
test.IsA(six.text_type), test.IsA(str),
databases=None, databases=None,
datastore=datastore, datastore=datastore,
datastore_version=datastore_version, datastore_version=datastore_version,
@ -1124,7 +1123,7 @@ class DatabaseTests(test.TestCase):
replica_count=2, replica_count=2,
volume_type=None, volume_type=None,
locality=None, locality=None,
availability_zone=test.IsA(six.text_type)) availability_zone=test.IsA(str))
self.assertRedirectsNoFollow(res, INDEX_URL) self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_mocks({ @test.create_mocks({
@ -1278,7 +1277,7 @@ class DatabaseTests(test.TestCase):
} }
res = self.client.post(url, form) res = self.client.post(url, form)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_configuration_list.assert_called_once_with( self.mock_configuration_list.assert_called_once_with(
test.IsHttpRequest()) test.IsHttpRequest())
self.mock_instance_attach_configuration.assert_called_once_with( self.mock_instance_attach_configuration.assert_called_once_with(
@ -1309,7 +1308,7 @@ class DatabaseTests(test.TestCase):
} }
res = self.client.post(url, form) res = self.client.post(url, form)
self.mock_instance_get.assert_called_once_with( self.mock_instance_get.assert_called_once_with(
test.IsHttpRequest(), test.IsA(six.text_type)) test.IsHttpRequest(), test.IsA(str))
self.mock_configuration_list.assert_called_once_with( self.mock_configuration_list.assert_called_once_with(
test.IsHttpRequest()) test.IsHttpRequest())
self.mock_instance_attach_configuration.assert_called_once_with( self.mock_instance_attach_configuration.assert_called_once_with(

View File

@ -21,8 +21,6 @@ from django.urls import reverse
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions from horizon import exceptions
from horizon import forms as horizon_forms from horizon import forms as horizon_forms
from horizon import tables as horizon_tables from horizon import tables as horizon_tables
@ -58,7 +56,7 @@ class IndexView(horizon_tables.DataTableView):
flavors = [] flavors = []
msg = _('Unable to retrieve database size information.') msg = _('Unable to retrieve database size information.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return OrderedDict((six.text_type(flavor.id), flavor) return OrderedDict((str(flavor.id), flavor)
for flavor in flavors) for flavor in flavors)
def _extra_data(self, instance): def _extra_data(self, instance):

View File

@ -12,27 +12,14 @@
# under the License. # under the License.
import binascii import binascii
import six
def hexlify(text): def hexlify(text):
"""Hexlify raw text, return hexlified text.""" """Hexlify raw text, return hexlified text."""
if six.PY3: text = text.encode('utf-8')
text = text.encode('utf-8') return binascii.hexlify(text).decode('utf-8')
hexlified = binascii.hexlify(text)
if six.PY3:
hexlified = hexlified.decode('utf-8')
return hexlified
def unhexlify(text): def unhexlify(text):
"""Unhexlify raw text, return unhexlified text.""" """Unhexlify raw text, return unhexlified text."""
unhexlified = binascii.unhexlify(text) return binascii.unhexlify(text).decode('utf-8')
if six.PY3:
unhexlified = unhexlified.decode('utf-8')
return unhexlified