]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Gate on H703
authorDirk Mueller <dirk@dmllr.de>
Tue, 11 Jun 2013 18:17:18 +0000 (20:17 +0200)
committerDirk Mueller <dirk@dmllr.de>
Wed, 12 Jun 2013 15:59:01 +0000 (17:59 +0200)
Fix fallout by avoiding multiple positional arguments.

Change-Id: Ie25f7b9041fa5df85a244cb237124440bb7d8e32

heat/api/cfn/v1/stacks.py
heat/api/middleware/version_negotiation.py
heat/common/auth.py
heat/common/wsgi.py
tox.ini

index dab7ad4a8ddf0b46fde97b0231817d0f3f9ccfd0..def26b00a5cb2003c989be0f5e28c4e305fc3c4f 100644 (file)
@@ -291,7 +291,7 @@ class StackController(object):
             return result
 
         if action not in self.CREATE_OR_UPDATE_ACTION:
-            msg = _('Unexpected action %s') % action
+            msg = _("Unexpected action %(action)s") % ({'action': action})
             # This should not happen, so return HeatInternalFailureError
             return exception.HeatInternalFailureError(detail=msg)
 
index c484d9e01e33f03df4d3298be087c13fee6b1032..1aff84f6919067c3898c192f95c1ed3905d3fdfa 100644 (file)
@@ -56,19 +56,23 @@ class VersionNegotiationFilter(wsgi.Middleware):
 
         match = self._match_version_string(req.path_info_peek(), req)
         if match:
-            if (req.environ['api.major_version'] == 1 and
-                    req.environ['api.minor_version'] == 0):
-                logger.debug(_("Matched versioned URI. Version: %d.%d"),
-                             req.environ['api.major_version'],
-                             req.environ['api.minor_version'])
+            major_version = req.environ['api.major_version']
+            minor_version = req.environ['api.minor_version']
+
+            if (major_version == 1 and minor_version == 0):
+                logger.debug(_("Matched versioned URI. "
+                               "Version: %(major_version)d.%(minor_version)d")
+                             % {'major_version': major_version,
+                                'minor_version': minor_version})
                 # Strip the version from the path
                 req.path_info_pop()
                 return None
             else:
-                logger.debug(_("Unknown version in versioned URI: %d.%d. "
-                             "Returning version choices."),
-                             req.environ['api.major_version'],
-                             req.environ['api.minor_version'])
+                logger.debug(_("Unknown version in versioned URI: "
+                             "%(major_version)d.%(minor_version)d. "
+                             "Returning version choices.")
+                             % {'major_version': major_version,
+                                'minor_version': minor_version})
                 return self.versions_app
 
         accept = str(req.accept)
@@ -77,18 +81,20 @@ class VersionNegotiationFilter(wsgi.Middleware):
             accept_version = accept[token_loc:]
             match = self._match_version_string(accept_version, req)
             if match:
-                if (req.environ['api.major_version'] == 1 and
-                        req.environ['api.minor_version'] == 0):
-                    logger.debug(_("Matched versioned media type. "
-                                 "Version: %d.%d"),
-                                 req.environ['api.major_version'],
-                                 req.environ['api.minor_version'])
+                major_version = req.environ['api.major_version']
+                minor_version = req.environ['api.minor_version']
+                if (major_version == 1 and minor_version == 0):
+                    logger.debug(_("Matched versioned media type. Version: "
+                                   "%(major_version)d.%(minor_version)d")
+                                 % {'major_version': major_version,
+                                    'minor_version': minor_version})
                     return None
                 else:
-                    logger.debug(_("Unknown version in accept header: %d.%d..."
-                                 "returning version choices."),
-                                 req.environ['api.major_version'],
-                                 req.environ['api.minor_version'])
+                    logger.debug(_("Unknown version in accept header: "
+                                   "%(major_version)d.%(minor_version)d..."
+                                   "returning version choices.")
+                                 % {'major_version': major_version,
+                                     'minor_version': minor_version})
                     return self.versions_app
         else:
             if req.accept not in ('*/*', ''):
index 4064f1e9b06807a27b830f2cd93b6a9373461014..290de4e15b80df951480b0fa5b847a0066990950 100644 (file)
@@ -176,7 +176,9 @@ class KeystoneStrategy(BaseStrategy):
         elif resp.status == 404:
             raise exception.AuthUrlNotFound(url=token_url)
         else:
-            raise Exception(_('Unexpected response: %s') % resp.status)
+            status = resp.status
+            raise Exception(_('Unexpected response: %(status)s')
+                            % {'status': resp.status})
 
     def _v2_auth(self, token_url):
         def get_endpoint(service_catalog):
index fcfa274230f912c52dd8661942d9034d6dee1e1b..d152f26ec4835a85a76388c36885d9749e515025 100644 (file)
@@ -130,8 +130,9 @@ def get_socket(conf, default_port):
                 raise
             eventlet.sleep(0.1)
     if not sock:
-        raise RuntimeError(_("Could not bind to %s:%s after trying for 30 "
-                             "seconds") % bind_addr)
+        raise RuntimeError(_("Could not bind to %(bind_addr)s"
+                             "after trying for 30 seconds")
+                           % {'bind_addr': bind_addr})
     sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     # in my experience, sockets can hang around forever without keepalive
     sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
diff --git a/tox.ini b/tox.ini
index 46d7f085c6fd7862262677b0a1b10e3d93c87ed2..1dde0d5f0187bc592b937e0ab14144855b95cd21 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -22,7 +22,6 @@ commands =
   python setup.py testr --coverage
 
 [flake8]
-ignore = F403,F841,H201,H302,H303,H306,H404,H703
 # F403 'from sqlalchemy import *' used; unable to detect undefined names
 # F841 local variable 'json_template' is assigned to but never used
 # H201 no 'except:' at least use 'except Exception:'
@@ -30,7 +29,7 @@ ignore = F403,F841,H201,H302,H303,H306,H404,H703
 # H303 No wildcard (*) import.
 # H306 imports not in alphabetical order
 # H404 multi line docstring should start with a summary
-# H703 Multiple positional placeholders
+ignore = F403,F841,H201,H302,H303,H306,H404
 show-source = true
 builtins = _
 exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,build