From 4c6ce2f938d239f5ade14cbbeb7a56b81e45404c Mon Sep 17 00:00:00 2001
From: Luong Anh Tuan <tuanla@vn.fujitsu.com>
Date: Wed, 28 Sep 2016 16:09:10 +0700
Subject: [PATCH] Avoid Forcing the Translation of Translatable Variables

Whenever possible translation should not be forced by use of six.text_type()
or str() on messages being used with a format string.

http://docs.openstack.org/developer/oslo.i18n/guidelines.html#avoid-forcing-the-translation-of-translatable-variables

Change-Id: If8eeeebd6fafc647a632bdff5636f82d383e2164
---
 manila/api/extensions.py                           | 4 +---
 manila/api/middleware/fault.py                     | 2 +-
 manila/api/openstack/wsgi.py                       | 4 ++--
 manila/data/utils.py                               | 5 ++---
 manila/share/api.py                                | 4 ++--
 manila/share/drivers/container/container_helper.py | 2 +-
 manila/share/manager.py                            | 2 +-
 manila/utils.py                                    | 2 +-
 8 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/manila/api/extensions.py b/manila/api/extensions.py
index 542979746b..2778387c47 100644
--- a/manila/api/extensions.py
+++ b/manila/api/extensions.py
@@ -19,7 +19,6 @@ import os
 from oslo_config import cfg
 from oslo_log import log
 from oslo_utils import importutils
-import six
 import webob.dec
 import webob.exc
 
@@ -183,8 +182,7 @@ class ExtensionManager(object):
                       ' '.join(extension.__doc__.strip().split()))
             LOG.debug('Ext updated: %s', extension.updated)
         except AttributeError as ex:
-            LOG.exception(_LE("Exception loading extension: %s"),
-                          six.text_type(ex))
+            LOG.exception(_LE("Exception loading extension: %s"), ex)
             return False
 
         return True
diff --git a/manila/api/middleware/fault.py b/manila/api/middleware/fault.py
index ee761ac555..32c5b95821 100644
--- a/manila/api/middleware/fault.py
+++ b/manila/api/middleware/fault.py
@@ -41,7 +41,7 @@ class FaultWrapper(base_wsgi.Middleware):
             status, webob.exc.HTTPInternalServerError)()
 
     def _error(self, inner, req):
-        LOG.exception(_LE("Caught error: %s"), six.text_type(inner))
+        LOG.exception(_LE("Caught error: %s"), inner)
 
         safe = getattr(inner, 'safe', False)
         headers = getattr(inner, 'headers', None)
diff --git a/manila/api/openstack/wsgi.py b/manila/api/openstack/wsgi.py
index b7ba7e9ed2..34614a23a9 100644
--- a/manila/api/openstack/wsgi.py
+++ b/manila/api/openstack/wsgi.py
@@ -528,10 +528,10 @@ class ResourceExceptionHandler(object):
                       ex_value, exc_info=exc_info)
             raise Fault(webob.exc.HTTPBadRequest())
         elif isinstance(ex_value, Fault):
-            LOG.info(_LI("Fault thrown: %s"), six.text_type(ex_value))
+            LOG.info(_LI("Fault thrown: %s"), ex_value)
             raise ex_value
         elif isinstance(ex_value, webob.exc.HTTPException):
-            LOG.info(_LI("HTTP exception thrown: %s"), six.text_type(ex_value))
+            LOG.info(_LI("HTTP exception thrown: %s"), ex_value)
             raise Fault(ex_value)
 
         # We didn't handle the exception
diff --git a/manila/data/utils.py b/manila/data/utils.py
index b22460a0e5..eb37e57d29 100644
--- a/manila/data/utils.py
+++ b/manila/data/utils.py
@@ -15,7 +15,6 @@
 import os
 
 from oslo_log import log
-import six
 
 from manila import exception
 from manila.i18n import _
@@ -89,7 +88,7 @@ class Copy(object):
         self.copy_stats(self.src)
         self.completed = True
 
-        LOG.info(six.text_type(self.get_progress()))
+        LOG.info(self.get_progress())
 
     def get_total_size(self, path):
         if self.cancelled:
@@ -144,7 +143,7 @@ class Copy(object):
                 self._copy_and_validate(src_item, dest_item)
 
                 self.current_size += int(size)
-                LOG.info(six.text_type(self.get_progress()))
+                LOG.info(self.get_progress())
 
     @utils.retry(exception.ShareDataCopyFailed, retries=2)
     def _copy_and_validate(self, src_item, dest_item):
diff --git a/manila/share/api.py b/manila/share/api.py
index d3f7e0f516..c94d82e63f 100644
--- a/manila/share/api.py
+++ b/manila/share/api.py
@@ -1235,7 +1235,7 @@ class API(base.Base):
         if search_opts is None:
             search_opts = {}
 
-        LOG.debug("Searching for shares by: %s", six.text_type(search_opts))
+        LOG.debug("Searching for shares by: %s", search_opts)
 
         # Prepare filters
         filters = {}
@@ -1302,7 +1302,7 @@ class API(base.Base):
         policy.check_policy(context, 'share_snapshot', 'get_all_snapshots')
 
         search_opts = search_opts or {}
-        LOG.debug("Searching for snapshots by: %s", six.text_type(search_opts))
+        LOG.debug("Searching for snapshots by: %s", search_opts)
 
         # Read and remove key 'all_tenants' if was provided
         all_tenants = search_opts.pop('all_tenants', None)
diff --git a/manila/share/drivers/container/container_helper.py b/manila/share/drivers/container/container_helper.py
index b1518ef52d..f69f5be83f 100644
--- a/manila/share/drivers/container/container_helper.py
+++ b/manila/share/drivers/container/container_helper.py
@@ -86,7 +86,7 @@ class DockerExecHelper(driver.ExecuteMixin):
         LOG.debug("Executing inside a container %s.", name)
         cmd = ["docker", "exec", "-i", name] + cmd
         result = self._inner_execute(cmd)
-        LOG.debug("Run result: %s.", str(result))
+        LOG.debug("Run result: %s.", result)
         return result
 
     def _inner_execute(self, cmd):
diff --git a/manila/share/manager.py b/manila/share/manager.py
index 12b704eb37..136ffaddfc 100644
--- a/manila/share/manager.py
+++ b/manila/share/manager.py
@@ -2030,7 +2030,7 @@ class ShareManager(manager.SchedulerDependentManager):
         def share_manage_set_error_status(msg, exception):
             status = {'status': constants.STATUS_UNMANAGE_ERROR}
             self.db.share_update(context, share_id, status)
-            LOG.error(msg, six.text_type(exception))
+            LOG.error(msg, exception)
 
         try:
             if self.driver.driver_handles_share_servers:
diff --git a/manila/utils.py b/manila/utils.py
index 61fb2835fd..e1d47b9660 100644
--- a/manila/utils.py
+++ b/manila/utils.py
@@ -448,7 +448,7 @@ def tempdir(**kwargs):
         try:
             shutil.rmtree(tmpdir)
         except OSError as e:
-            LOG.debug('Could not remove tmpdir: %s', six.text_type(e))
+            LOG.debug('Could not remove tmpdir: %s', e)
 
 
 def walk_class_hierarchy(clazz, encountered=None):