]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
cinder/.: replace 'locals()' with explicit values
authorAndrew Forrest <forrest@research.att.com>
Sat, 15 Jun 2013 18:09:33 +0000 (11:09 -0700)
committerAndrew Forrest <forrest@research.att.com>
Mon, 17 Jun 2013 15:51:11 +0000 (08:51 -0700)
Help bring source code into compliance with the Cinder Style Commandments:
https://github.com/openstack/cinder/blob/master/HACKING.rst

This change covers all affected source directly in the top-level directory
of the cinder module, i.e. cinder/*.py

Partially fixes: bug #1190748

Change-Id: Ice5efc5eda7189969af6a9b722344fad7aa49ff0

cinder/exception.py
cinder/quota.py
cinder/service.py
cinder/test.py
cinder/utils.py

index c668e140407e8b312b4b8a9a8eabea8d5d62a1f2..a028a5686ca641137abc6750b3900af85c548264 100644 (file)
@@ -66,7 +66,13 @@ class ProcessExecutionError(IOError):
             exit_code = '-'
         message = _('%(description)s\nCommand: %(cmd)s\n'
                     'Exit code: %(exit_code)s\nStdout: %(stdout)r\n'
-                    'Stderr: %(stderr)r') % locals()
+                    'Stderr: %(stderr)r') % {
+                        'description': description,
+                        'cmd': cmd,
+                        'exit_code': exit_code,
+                        'stdout': stdout,
+                        'stderr': stderr,
+                    }
         IOError.__init__(self, message)
 
 
index 3f9b174ecd3851a2cdb0656cd173a4b1d1fc661d..59b03bf0193227db4ddbbe086f5d4162e358f051 100644 (file)
@@ -702,7 +702,7 @@ class QuotaEngine(object):
                                             expire=expire,
                                             project_id=project_id)
 
-        LOG.debug(_("Created reservations %(reservations)s") % locals())
+        LOG.debug(_("Created reservations %s") % reservations)
 
         return reservations
 
@@ -724,8 +724,7 @@ class QuotaEngine(object):
             # usage resynchronization and the reservation expiration
             # mechanisms will resolve the issue.  The exception is
             # logged, however, because this is less than optimal.
-            LOG.exception(_("Failed to commit reservations "
-                            "%(reservations)s") % locals())
+            LOG.exception(_("Failed to commit reservations %s") % reservations)
 
     def rollback(self, context, reservations, project_id=None):
         """Roll back reservations.
@@ -746,7 +745,7 @@ class QuotaEngine(object):
             # mechanisms will resolve the issue.  The exception is
             # logged, however, because this is less than optimal.
             LOG.exception(_("Failed to roll back reservations "
-                            "%(reservations)s") % locals())
+                            "%s") % reservations)
 
     def destroy_all_by_project(self, context, project_id):
         """
index 3ffd7f8924624d2b0e14683c0e8e5708f619d4a2..c8d374895dcc0471f9cfeb58ca7c81bf5f4b9c76 100644 (file)
@@ -270,10 +270,12 @@ class ProcessLauncher(object):
         code = 0
         if os.WIFSIGNALED(status):
             sig = os.WTERMSIG(status)
-            LOG.info(_('Child %(pid)d killed by signal %(sig)d'), locals())
+            LOG.info(_('Child %(pid)d killed by signal %(sig)d'),
+                     {'pid': pid, 'sig': sig})
         else:
             code = os.WEXITSTATUS(status)
-            LOG.info(_('Child %(pid)d exited with status %(code)d'), locals())
+            LOG.info(_('Child %(pid)d exited with status %(code)d'),
+                     {'pid': pid, 'code': code})
 
         if pid not in self.children:
             LOG.warning(_('pid %d not in child list'), pid)
@@ -613,9 +615,10 @@ def wait():
         # should use secret flag when switch over to openstack-common
         if ("_password" in flag or "_key" in flag or
                 (flag == "sql_connection" and "mysql:" in flag_get)):
-            LOG.debug(_('%(flag)s : FLAG SET ') % locals())
+            LOG.debug(_('%s : FLAG SET ') % flag)
         else:
-            LOG.debug('%(flag)s : %(flag_get)s' % locals())
+            LOG.debug('%(flag)s : %(flag_get)s' %
+                      {'flag': flag, 'flag_get': flag_get})
     try:
         _launcher.wait()
     except KeyboardInterrupt:
index bebe950a84013a1c1625aaef4d6943d33446fe06..59d3bacdb2d7c04f13634e2346d42c04b6c4344d 100644 (file)
@@ -223,7 +223,8 @@ class TestCase(testtools.TestCase):
             d1str = str(d1)
             d2str = str(d2)
             base_msg = ('Dictionaries do not match. %(msg)s d1: %(d1str)s '
-                        'd2: %(d2str)s' % locals())
+                        'd2: %(d2str)s' %
+                        {'msg': msg, 'd1str': d1str, 'd2str': d2str})
             raise AssertionError(base_msg)
 
         d1keys = set(d1.keys())
@@ -232,7 +233,8 @@ class TestCase(testtools.TestCase):
             d1only = d1keys - d2keys
             d2only = d2keys - d1keys
             raise_assertion('Keys in d1 and not d2: %(d1only)s. '
-                            'Keys in d2 and not d1: %(d2only)s' % locals())
+                            'Keys in d2 and not d1: %(d2only)s' %
+                            {'d1only': d1only, 'd2only': d2only})
 
         for key in d1keys:
             d1value = d1[key]
@@ -254,7 +256,12 @@ class TestCase(testtools.TestCase):
                 continue
             elif d1value != d2value:
                 raise_assertion("d1['%(key)s']=%(d1value)s != "
-                                "d2['%(key)s']=%(d2value)s" % locals())
+                                "d2['%(key)s']=%(d2value)s" %
+                                {
+                                    'key': key,
+                                    'd1value': d1value,
+                                    'd2value': d2value,
+                                })
 
     def assertDictListMatch(self, L1, L2, approx_equal=False, tolerance=0.001):
         """Assert a list of dicts are equivalent."""
@@ -262,14 +269,16 @@ class TestCase(testtools.TestCase):
             L1str = str(L1)
             L2str = str(L2)
             base_msg = ('List of dictionaries do not match: %(msg)s '
-                        'L1: %(L1str)s L2: %(L2str)s' % locals())
+                        'L1: %(L1str)s L2: %(L2str)s' %
+                        {'msg': msg, 'L1str': L1str, 'L2str': L2str})
             raise AssertionError(base_msg)
 
         L1count = len(L1)
         L2count = len(L2)
         if L1count != L2count:
             raise_assertion('Length mismatch: len(L1)=%(L1count)d != '
-                            'len(L2)=%(L2count)d' % locals())
+                            'len(L2)=%(L2count)d' %
+                            {'L1count': L1count, 'L2count': L2count})
 
         for d1, d2 in zip(L1, L2):
             self.assertDictMatch(d1, d2, approx_equal=approx_equal,
index b2464d414e18419fd6a2d5d3e6f3d8f60eca9415..c9c33bf5a9229e1b450e3dd414bf6632a2f61808 100644 (file)
@@ -530,7 +530,8 @@ def get_my_linklocal(interface):
                                   % if_str)
     except Exception as ex:
         raise exception.Error(_("Couldn't get Link Local IP of %(interface)s"
-                                " :%(ex)s") % locals())
+                                " :%(ex)s") %
+                              {'interface': interface, 'ex': ex, })
 
 
 def parse_mailmap(mailmap='.mailmap'):