From 48e1a87c8493483b6b7e0a5a21b650f2ab7ac52b Mon Sep 17 00:00:00 2001 From: caoyue Date: Wed, 4 May 2016 14:59:12 +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: I0d7018e086d6e68d432eefdc098527e38e7e27d7 Closes-Bug: #1321274 --- tacker/common/rpc_compat.py | 2 +- tacker/openstack/common/fileutils.py | 2 +- tacker/openstack/common/loopingcall.py | 2 +- tacker/openstack/common/middleware/notifier.py | 2 +- tacker/openstack/common/policy.py | 6 +++--- tacker/openstack/common/processutils.py | 2 +- tacker/vm/tosca/utils.py | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tacker/common/rpc_compat.py b/tacker/common/rpc_compat.py index 58f2a9389..92518d314 100644 --- a/tacker/common/rpc_compat.py +++ b/tacker/common/rpc_compat.py @@ -107,7 +107,7 @@ class Service(service.Service): super(Service, self).start() self.conn = create_connection(new=True) - LOG.debug("Creating Consumer connection for Service %s" % + LOG.debug("Creating Consumer connection for Service %s", self.topic) endpoints = [self.manager] diff --git a/tacker/openstack/common/fileutils.py b/tacker/openstack/common/fileutils.py index 5e1c98267..46f3a8a14 100644 --- a/tacker/openstack/common/fileutils.py +++ b/tacker/openstack/common/fileutils.py @@ -60,7 +60,7 @@ def read_cached_file(filename, force_reload=False): cache_info = _FILE_CACHE.setdefault(filename, {}) if not cache_info or mtime > cache_info.get('mtime', 0): - LOG.debug(_("Reloading cached file %s") % filename) + LOG.debug(_("Reloading cached file %s"), filename) with open(filename) as fap: cache_info['data'] = fap.read() cache_info['mtime'] = mtime diff --git a/tacker/openstack/common/loopingcall.py b/tacker/openstack/common/loopingcall.py index f226d0419..c644503f4 100644 --- a/tacker/openstack/common/loopingcall.py +++ b/tacker/openstack/common/loopingcall.py @@ -80,7 +80,7 @@ class FixedIntervalLoopingCall(LoopingCallBase): delay = interval - timeutils.delta_seconds(start, end) if delay <= 0: LOG.warning(_('task run outlasted interval by %s ' - 'sec') % -delay) + 'sec'), -delay) greenthread.sleep(delay if delay > 0 else 0) except LoopingCallDone as e: self.stop() diff --git a/tacker/openstack/common/middleware/notifier.py b/tacker/openstack/common/middleware/notifier.py index 7c0d9cf0b..44201b4f9 100644 --- a/tacker/openstack/common/middleware/notifier.py +++ b/tacker/openstack/common/middleware/notifier.py @@ -38,7 +38,7 @@ def log_and_ignore_error(fn): return fn(*args, **kwargs) except Exception as e: LOG.exception(_LE('An exception occurred processing ' - 'the API call: %s ') % e) + 'the API call: %s '), e) return wrapped diff --git a/tacker/openstack/common/policy.py b/tacker/openstack/common/policy.py index b778ef5e1..ba458a7c1 100644 --- a/tacker/openstack/common/policy.py +++ b/tacker/openstack/common/policy.py @@ -391,7 +391,7 @@ def _parse_check(rule): try: kind, match = rule.split(':', 1) except Exception: - LOG.exception(_("Failed to understand rule %(rule)s") % locals()) + LOG.exception(_("Failed to understand rule %(rule)s"), locals()) # If the rule is invalid, we'll fail closed return FalseCheck() @@ -401,7 +401,7 @@ def _parse_check(rule): elif None in _checks: return _checks[None](kind, match) else: - LOG.error(_("No handler for matches of kind %s") % kind) + LOG.error(_("No handler for matches of kind %s"), kind) return FalseCheck() @@ -676,7 +676,7 @@ def _parse_text_rule(rule): return state.result except ValueError: # Couldn't parse the rule - LOG.exception(_("Failed to understand rule %(rule)r") % locals()) + LOG.exception(_("Failed to understand rule %(rule)r"), locals()) # Fail closed return FalseCheck() diff --git a/tacker/openstack/common/processutils.py b/tacker/openstack/common/processutils.py index b7e5411c6..8ea97ad6f 100644 --- a/tacker/openstack/common/processutils.py +++ b/tacker/openstack/common/processutils.py @@ -238,7 +238,7 @@ def ssh_execute(ssh, cmd, process_input=None, # exit_status == -1 if no exit code was returned if exit_status != -1: - LOG.debug(_('Result was %s') % exit_status) + LOG.debug(_('Result was %s'), exit_status) if check_exit_code and exit_status != 0: raise ProcessExecutionError(exit_code=exit_status, stdout=stdout, diff --git a/tacker/vm/tosca/utils.py b/tacker/vm/tosca/utils.py index da06813f6..a813c9ba8 100644 --- a/tacker/vm/tosca/utils.py +++ b/tacker/vm/tosca/utils.py @@ -95,7 +95,7 @@ def updateimports(template): template['imports'].append(nfvfile) - LOG.debug(_("%s") % path) + LOG.debug(_("%s"), path) @log.log @@ -131,7 +131,7 @@ def get_mgmt_ports(tosca): if vdu is not None: name = 'mgmt_ip-%s' % vdu mgmt_ports[name] = nt.name - LOG.debug('mgmt_ports: %s' % mgmt_ports) + LOG.debug('mgmt_ports: %s', mgmt_ports) return mgmt_ports @@ -185,7 +185,7 @@ def post_process_heat_template(heat_tpl, mgmt_ports, res_tpl, heat_dict['outputs'].update(output) else: heat_dict['outputs'] = output - LOG.debug(_('Added output for %s') % outputname) + LOG.debug(_('Added output for %s'), outputname) add_resources_tpl(heat_dict, res_tpl) if unsupported_res_prop: convert_unsupported_res_prop(heat_dict, unsupported_res_prop)