From 09dfc861c816c1c778897bfb37e1ee5bd616a523 Mon Sep 17 00:00:00 2001 From: "ting.wang" Date: Wed, 10 Feb 2016 22:53:50 +0800 Subject: [PATCH] replace string format arguments with function parameters There are files containing string format arguments inside logging messages. Using logging function parameters should be preferred. Change-Id: Ic053903056ba3479a787aad6e9a359ba1efc35f8 Closes-Bug: #1321274 --- manila/share/api.py | 2 +- manila/share/driver.py | 2 +- manila/share/manager.py | 8 ++++---- manila/share/migration.py | 4 ++-- manila/tests/fake_utils.py | 2 +- manila/tests/integrated/api/client.py | 6 +++--- manila/tests/integrated/integrated_helpers.py | 6 +++--- manila/tests/integrated/test_extensions.py | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/manila/share/api.py b/manila/share/api.py index ab90fc6b..2d07701b 100644 --- a/manila/share/api.py +++ b/manila/share/api.py @@ -364,7 +364,7 @@ class API(base.Base): 'scheduled_at': timeutils.utcnow(), }) - LOG.debug("Manage: Found shares %s" % len(shares)) + LOG.debug("Manage: Found shares %s.", len(shares)) retry_states = (constants.STATUS_MANAGE_ERROR,) diff --git a/manila/share/driver.py b/manila/share/driver.py index f0ee3dca..143de526 100644 --- a/manila/share/driver.py +++ b/manila/share/driver.py @@ -543,7 +543,7 @@ class ShareDriver(object): 'new_instance_id': new_share_instance['id']}) raise exception.ShareMigrationFailed(reason=msg) - LOG.debug("Copying completed in migration for share %s." % share['id']) + LOG.debug("Copying completed in migration for share %s.", share['id']) def create_share(self, context, share, share_server=None): """Is called to create share.""" diff --git a/manila/share/manager.py b/manila/share/manager.py index d42439a4..a7e585e0 100644 --- a/manila/share/manager.py +++ b/manila/share/manager.py @@ -542,7 +542,7 @@ class ShareManager(manager.SchedulerDependentManager): @utils.require_driver_initialized def migrate_share(self, ctxt, share_id, host, force_host_copy=False): """Migrates a share from current host to another host.""" - LOG.debug("Entered migrate_share method for share %s." % share_id) + LOG.debug("Entered migrate_share method for share %s.", share_id) # NOTE(ganso): Cinder checks if driver is initialized before doing # anything. This might not be needed, as this code may not be reached @@ -577,7 +577,7 @@ class ShareManager(manager.SchedulerDependentManager): dest_driver_migration_info = rpcapi.get_driver_migration_info( ctxt, share_instance, share_server) - LOG.debug("Calling driver migration for share %s." % share_id) + LOG.debug("Calling driver migration for share %s.", share_id) moved, model_update = self.driver.migrate_share( ctxt, share_instance, host, dest_driver_migration_info) @@ -598,7 +598,7 @@ class ShareManager(manager.SchedulerDependentManager): if not moved: try: LOG.debug("Starting generic migration " - "for share %s." % share_id) + "for share %s.", share_id) moved = self._migrate_share_generic(ctxt, share_ref, host) except Exception as e: @@ -657,7 +657,7 @@ class ShareManager(manager.SchedulerDependentManager): ) LOG.debug("Time to start copying in migration" - " for share %s." % share['id']) + " for share %s.", share['id']) share_server = self._get_share_server(context.elevated(), share_instance) diff --git a/manila/share/migration.py b/manila/share/migration.py index f45aeb96..adecf5c4 100644 --- a/manila/share/migration.py +++ b/manila/share/migration.py @@ -263,7 +263,7 @@ class ShareMigrationHelper(object): if readonly_support: LOG.debug("Changing all of share %s access rules " - "to read-only." % self.share['id']) + "to read-only.", self.share['id']) self.add_rules_and_wait(self.context, self.share, saved_rules, 'ro') @@ -278,7 +278,7 @@ class ShareMigrationHelper(object): self.context, self.share['id']) LOG.debug("Removing all of share %s read-only " - "access rules." % self.share['id']) + "access rules.", self.share['id']) self.deny_rules_and_wait(self.context, self.share, readonly_rules) diff --git a/manila/tests/fake_utils.py b/manila/tests/fake_utils.py index b56d49cb..0cdf3ffc 100644 --- a/manila/tests/fake_utils.py +++ b/manila/tests/fake_utils.py @@ -98,7 +98,7 @@ def fake_execute(*cmd_parts, **kwargs): stdout = reply[0] stderr = reply[1] LOG.debug("Reply to faked command is stdout='%(stdout)s' " - "stderr='%(stderr)s'" % {"stdout": stdout, "stderr": stderr}) + "stderr='%(stderr)s'.", {"stdout": stdout, "stderr": stderr}) # Replicate the sleep call in the real function greenthread.sleep(0) diff --git a/manila/tests/integrated/api/client.py b/manila/tests/integrated/api/client.py index 9e41cec0..6ae99464 100644 --- a/manila/tests/integrated/api/client.py +++ b/manila/tests/integrated/api/client.py @@ -122,7 +122,7 @@ class TestOpenStackClient(object): headers=headers) http_status = response.status - LOG.debug("%(auth_uri)s => code %(http_status)s" % + LOG.debug("%(auth_uri)s => code %(http_status)s.", {"auth_uri": auth_uri, "http_status": http_status}) if http_status == 401: @@ -148,7 +148,7 @@ class TestOpenStackClient(object): response = self.request(full_uri, **kwargs) http_status = response.status - LOG.debug("%(relative_uri)s => code %(http_status)s" % + LOG.debug("%(relative_uri)s => code %(http_status)s.", {"relative_uri": relative_uri, "http_status": http_status}) if check_response_status: @@ -166,7 +166,7 @@ class TestOpenStackClient(object): def _decode_json(self, response): body = response.read() - LOG.debug("Decoding JSON: %s" % (body)) + LOG.debug("Decoding JSON: %s.", (body)) if body: return jsonutils.loads(body) else: diff --git a/manila/tests/integrated/integrated_helpers.py b/manila/tests/integrated/integrated_helpers.py index ca4d62bb..df3da066 100644 --- a/manila/tests/integrated/integrated_helpers.py +++ b/manila/tests/integrated/integrated_helpers.py @@ -54,7 +54,7 @@ def generate_new_element(items, prefix, numeric=False): candidate = prefix + generate_random_alphanumeric(8) if candidate not in items: return candidate - LOG.debug("Random collision on %s" % candidate) + LOG.debug("Random collision on %s.", candidate) class _IntegratedTestBase(test.TestCase): @@ -109,7 +109,7 @@ class _IntegratedTestBase(test.TestCase): server = {} image = self.api.get_images()[0] - LOG.debug("Image: %s" % image) + LOG.debug("Image: %s.", image) if 'imageRef' in image: image_href = image['imageRef'] @@ -122,7 +122,7 @@ class _IntegratedTestBase(test.TestCase): # Set a valid flavorId flavor = self.api.get_flavors()[0] - LOG.debug("Using flavor: %s" % flavor) + LOG.debug("Using flavor: %s.", flavor) server['flavorRef'] = 'http://fake.server/%s' % flavor['id'] # Set a valid server name diff --git a/manila/tests/integrated/test_extensions.py b/manila/tests/integrated/test_extensions.py index 8ab75431..716fc724 100644 --- a/manila/tests/integrated/test_extensions.py +++ b/manila/tests/integrated/test_extensions.py @@ -35,5 +35,5 @@ class ExtensionsTest(integrated_helpers._IntegratedTestBase): """Simple check that fox-n-socks works.""" response = self.api.api_request('/foxnsocks') foxnsocks = response.read() - LOG.debug("foxnsocks: %s" % foxnsocks) + LOG.debug("foxnsocks: %s.", foxnsocks) self.assertEqual(six.b('Try to say this Mr. Knox, sir...'), foxnsocks)