diff --git a/avocado/core/job.py b/avocado/core/job.py index 58bef90e1d58611c3cc75884c4b13bb61cc2dece..1ff79a9cd73200a08ac8a35ffa0a89f5d5c7dd98 100644 --- a/avocado/core/job.py +++ b/avocado/core/job.py @@ -402,10 +402,10 @@ class Job(object): def _log_avocado_datadir(self): LOG_JOB.info('Avocado Data Directories:') LOG_JOB.info('') - LOG_JOB.info('base ' + data_dir.get_base_dir()) - LOG_JOB.info('tests ' + data_dir.get_test_dir()) - LOG_JOB.info('data ' + data_dir.get_data_dir()) - LOG_JOB.info('logs ' + self.logdir) + LOG_JOB.info('base %s', data_dir.get_base_dir()) + LOG_JOB.info('tests %s', data_dir.get_test_dir()) + LOG_JOB.info('data %s', data_dir.get_data_dir()) + LOG_JOB.info('logs %s', self.logdir) LOG_JOB.info('') @staticmethod @@ -540,7 +540,7 @@ class Job(object): self.exitcode |= exit_codes.AVOCADO_JOB_FAIL return self.exitcode except exceptions.OptionValidationError as details: - self.log.error('\n' + str(details)) + self.log.error('\n%s', str(details)) self.exitcode |= exit_codes.AVOCADO_JOB_FAIL return self.exitcode diff --git a/avocado/core/output.py b/avocado/core/output.py index 2495aa50ecced79c8befd69e221ce99c111658f6..064c52111b7fddeaf96262f4587b28c2f9ce6cf2 100644 --- a/avocado/core/output.py +++ b/avocado/core/output.py @@ -326,8 +326,7 @@ class StdOutput(object): except RuntimeError as details: # Paginator not available logging.getLogger('avocado.app.debug').error("Failed to enable " - "paginator: %s" - % details) + "paginator: %s", details) return self.stdout = self.stderr = paginator diff --git a/avocado/core/runner.py b/avocado/core/runner.py index 8b39fc6cfb7f7c55cffc4b15a6abd478b6b93347..ab2732cac53d012fa9c752b5ea50b6e3c27e3350 100644 --- a/avocado/core/runner.py +++ b/avocado/core/runner.py @@ -378,13 +378,14 @@ class TestRunner(object): return with sigtstp: msg = "ctrl+z pressed, %%s test (%s)" % proc.pid + app_log_msg = '\n%s' % msg if self.sigstopped: - APP_LOG.info("\n" + msg, "resumming") + APP_LOG.info(app_log_msg, "resumming") TEST_LOG.info(msg, "resumming") process.kill_process_tree(proc.pid, signal.SIGCONT, False) self.sigstopped = False else: - APP_LOG.info("\n" + msg, "stopping") + APP_LOG.info(app_log_msg, "stopping") TEST_LOG.info(msg, "stopping") process.kill_process_tree(proc.pid, signal.SIGSTOP, False) self.sigstopped = True diff --git a/avocado/core/sysinfo.py b/avocado/core/sysinfo.py index a7395e8f5694e6f86ddbd29757c5e66b5811bba7..c319d8af7e8fe334440d1c081c188657ab7a7d0f 100644 --- a/avocado/core/sysinfo.py +++ b/avocado/core/sysinfo.py @@ -213,7 +213,7 @@ class Daemon(Command): stderr=subprocess.STDOUT, shell=False, env=env) except OSError: - log.debug("Not logging %s (command could not be run)" % self.cmd) + log.debug("Not logging %s (command could not be run)", self.cmd) def stop(self): """ diff --git a/avocado/plugins/config.py b/avocado/plugins/config.py index 78f2911e2ccb76760a44ac43834967eeacc4c3c2..32e693f3f7f633eae25e06c6cde6c3e6eee2010f 100644 --- a/avocado/plugins/config.py +++ b/avocado/plugins/config.py @@ -39,11 +39,11 @@ class Config(CLICmd): def run(self, args): LOG_UI.info('Config files read (in order):') for cfg_path in settings.config_paths: - LOG_UI.debug(' %s' % cfg_path) + LOG_UI.debug(' %s', cfg_path) if settings.config_paths_failed: LOG_UI.error('\nConfig files that failed to read:') for cfg_path in settings.config_paths_failed: - LOG_UI.error(' %s' % cfg_path) + LOG_UI.error(' %s', cfg_path) LOG_UI.debug("") if not args.datadir: blength = 0 @@ -66,8 +66,8 @@ class Config(CLICmd): LOG_UI.debug("file to customize values") LOG_UI.debug('') LOG_UI.info('Avocado Data Directories:') - LOG_UI.debug(' base ' + data_dir.get_base_dir()) - LOG_UI.debug(' tests ' + data_dir.get_test_dir()) - LOG_UI.debug(' data ' + data_dir.get_data_dir()) - LOG_UI.debug(' logs ' + data_dir.get_logs_dir()) - LOG_UI.debug(' cache ' + ", ".join(data_dir.get_cache_dirs())) + LOG_UI.debug(' base %s', data_dir.get_base_dir()) + LOG_UI.debug(' tests %s', data_dir.get_test_dir()) + LOG_UI.debug(' data %s', data_dir.get_data_dir()) + LOG_UI.debug(' logs %s', data_dir.get_logs_dir()) + LOG_UI.debug(' cache %s', ", ".join(data_dir.get_cache_dirs())) diff --git a/avocado/utils/asset.py b/avocado/utils/asset.py index 8c35849c4a6ec5effc19731d75a037e592bf7198..85b42228aad96dcd616045ff3532b21357488e2d 100644 --- a/avocado/utils/asset.py +++ b/avocado/utils/asset.py @@ -159,7 +159,7 @@ class Asset(object): return asset_file except: exc_type, exc_value = sys.exc_info()[:2] - log.error('%s: %s' % (exc_type.__name__, exc_value)) + log.error('%s: %s', exc_type.__name__, exc_value) # If we get to this point, we have to download it from a location. # A writable cache directory is then needed. The first available @@ -190,7 +190,7 @@ class Asset(object): return asset_file except: exc_type, exc_value = sys.exc_info()[:2] - log.error('%s: %s' % (exc_type.__name__, exc_value)) + log.error('%s: %s', exc_type.__name__, exc_value) raise EnvironmentError("Failed to fetch %s." % basename) diff --git a/avocado/utils/data_factory.py b/avocado/utils/data_factory.py index 093cd0c3277a36e1b1156c57518cf6b8c277a17d..93106860781a85127e7b4e4ad5ace0c1fc182146 100644 --- a/avocado/utils/data_factory.py +++ b/avocado/utils/data_factory.py @@ -82,8 +82,8 @@ def make_dir_and_populate(basedir='/tmp'): os.write(fd, generate_random_string(str_length)) os.close(fd) except OSError as details: - log.error("Failed to generate dir in '%s' and populate: %s" % - (basedir, details)) + log_msg = "Failed to generate dir in '%s' and populate: %s" + log.error(log_msg, basedir, details) return None return path diff --git a/avocado/utils/download.py b/avocado/utils/download.py index 907c7fdc192967d0a10f4c35088758a6c5ca88a6..a2c3cdf5f6a8512ab27b275da926b7e87d024475 100644 --- a/avocado/utils/download.py +++ b/avocado/utils/download.py @@ -171,7 +171,7 @@ def get_file(src, dst, permissions=None, hash_expected=None, while not hash_file == hash_expected: hash_file = _verify_hash(_get_file(src, dst, permissions)) if hash_file != hash_expected: - log.error("It seems that dst %s is corrupted" % dst) + log.error("It seems that dst %s is corrupted", dst) download_failures += 1 if download_failures > download_retries: raise EnvironmentError("Failed to retrieve %s. " diff --git a/avocado/utils/genio.py b/avocado/utils/genio.py index 3b7cc5f752a2bb9f567919897f8577f9f237ff76..f00a047b6ad15d57b94ca0e67fa5ba445130c48a 100644 --- a/avocado/utils/genio.py +++ b/avocado/utils/genio.py @@ -99,7 +99,7 @@ def ask(question, auto=False): :rtype: str """ if auto: - log.info("%s (y/n) y" % question) + log.info("%s (y/n) y", question) return "y" return input("%s (y/n) " % question) diff --git a/avocado/utils/lv_utils.py b/avocado/utils/lv_utils.py index ff2806db706664f51f7175f7f87373b966ecd311..1af69477bd8b0641f83ce96f74fe654cc1511a7b 100644 --- a/avocado/utils/lv_utils.py +++ b/avocado/utils/lv_utils.py @@ -448,8 +448,8 @@ def lv_take_snapshot(vg_name, lv_name, re.search(re.escape(lv_snapshot_name + " [active]"), process.run("lvdisplay", sudo=True).stdout)): # the above conditions detect if merge of snapshot was postponed - LOGGER.debug(("Logical volume %s is still active! " + - "Attempting to deactivate..."), lv_name) + log_msg = "Logical volume %s is still active! Attempting to deactivate..." + LOGGER.debug(log_msg, lv_name) lv_reactivate(vg_name, lv_name) process.run(cmd, sudo=True) else: @@ -491,8 +491,8 @@ def lv_revert(vg_name, lv_name, lv_snapshot_name): if ('Snapshot could not be found' in ex.result.stderr and re.search(active_lv_pattern, lvdisplay_output) or "The Logical volume %s is still active" % lv_name in ex.result.stderr): - LOGGER.debug(("Logical volume %s is still active! " + - "Attempting to deactivate..."), lv_name) + log_msg = "Logical volume %s is still active! Attempting to deactivate..." + LOGGER.debug(log_msg, lv_name) lv_reactivate(vg_name, lv_name) LOGGER.error("Continuing after reactivation") elif 'Snapshot could not be found' in ex.result.stderr: @@ -533,8 +533,8 @@ def lv_reactivate(vg_name, lv_name, timeout=10): process.run("lvchange -ay /dev/%s/%s" % (vg_name, lv_name), sudo=True) time.sleep(timeout) except process.CmdError: - LOGGER.error(("Failed to reactivate %s - please, " + - "nuke the process that uses it first."), lv_name) + log_msg = "Failed to reactivate %s - please, nuke the process that uses it first." + LOGGER.error(log_msg, lv_name) raise LVException("The Logical volume %s is still active" % lv_name) diff --git a/avocado/utils/memory.py b/avocado/utils/memory.py index 9524c803eb22d5cdffc8cec7a8a78f3155e422be..27e8e756af2a2e6ab88b78dcb62db71b26fd6011 100644 --- a/avocado/utils/memory.py +++ b/avocado/utils/memory.py @@ -394,7 +394,7 @@ def get_buddy_info(chunk_sizes, nodes="all", zones="all"): re_buddyinfo += "(%s)" % "|".join(nodes.split()) if not re.findall(re_buddyinfo, buddy_info_content): - logging.warn("Can not find Nodes %s" % nodes) + logging.warn("Can not find Nodes %s", nodes) return None re_buddyinfo += r".*?zone\s+" if zones == "all": @@ -402,7 +402,7 @@ def get_buddy_info(chunk_sizes, nodes="all", zones="all"): else: re_buddyinfo += "(%s)" % "|".join(zones.split()) if not re.findall(re_buddyinfo, buddy_info_content): - logging.warn("Can not find zones %s" % zones) + logging.warn("Can not find zones %s", zones) return None re_buddyinfo += r"\s+([\s\d]+)" diff --git a/avocado/utils/software_manager.py b/avocado/utils/software_manager.py index 44b533f249277539a9f27b6a3bf6b5b6dbc7a6bb..3828a0c8c6aad8d5c9748c6751c3b28d5af35b58 100644 --- a/avocado/utils/software_manager.py +++ b/avocado/utils/software_manager.py @@ -662,7 +662,7 @@ class ZypperBackend(RpmBackend): except IndexError: ver = out self.pm_version = ver - log.debug('Zypper version: %s' % self.pm_version) + log.debug('Zypper version: %s', self.pm_version) def install(self, name): """ diff --git a/optional_plugins/html/avocado_result_html/__init__.py b/optional_plugins/html/avocado_result_html/__init__.py index e80931151935671a8a4a7019229b4ff4937ab4e7..fbffdb3a2df8ce8ab9200c7d672547b32afe8548 100644 --- a/optional_plugins/html/avocado_result_html/__init__.py +++ b/optional_plugins/html/avocado_result_html/__init__.py @@ -253,7 +253,7 @@ class HTMLResult(Result): report_contents = v.render('utf8') except UnicodeDecodeError as details: # FIXME: Remove me when UnicodeDecodeError problem is fixed - LOG_UI.critical("\n" + ("-" * 80)) + LOG_UI.critical("\n%s", ("-" * 80)) LOG_UI.critical("HTML failed to render the template: %s\n\n", template) LOG_UI.critical("-" * 80) diff --git a/optional_plugins/resultsdb/avocado_resultsdb/__init__.py b/optional_plugins/resultsdb/avocado_resultsdb/__init__.py index 3cc736022b08e958d9ed83ad71c055310d4742c3..b2982bd4a6f94430542468e4d0d91ad13bedace1 100644 --- a/optional_plugins/resultsdb/avocado_resultsdb/__init__.py +++ b/optional_plugins/resultsdb/avocado_resultsdb/__init__.py @@ -162,8 +162,8 @@ class ResultsdbResult(Result): def render(self, result, job): if (getattr(job.args, 'resultsdb_logs', None) is not None and getattr(job.args, 'stdout_claimed_by', None) is None): - LOG_UI.info("JOB URL : %s/%s" % (job.args.resultsdb_logs, - os.path.basename(job.logdir))) + log_msg = "JOB URL : %s/%s" + LOG_UI.info(log_msg, job.args.resultsdb_logs, os.path.basename(job.logdir)) class ResultsdbCLI(CLI): diff --git a/selftests/checkall b/selftests/checkall index bff99aafb3829d9b2070adfecac973a6122538f3..7e664c3c8a96d595738414149022018ecc97d777 100755 --- a/selftests/checkall +++ b/selftests/checkall @@ -169,7 +169,7 @@ results_dir_content() { [ "$SKIP_RESULTSDIR_CHECK" ] || RESULTS_DIR_CONTENT="$(ls $RESULTS_DIR 2> /dev/null)" LINT_CMD="inspekt lint --exclude=.git" -PYLINT_ENABLE="--enable R0401,W0101,W0102,W0104,W0105,W0106,W0107,W0108,W0109,W0111,W0120,W0122,W0123,W0124,W0125,W0150,W0199,W0211,W0222,W0232,W0233,W0301,W0312,W0401,W0404,W0406,W0410,W0601,W0602,W0603,W0604,W0611,W0612,W0614,W0622,W0623,W0640,W0711,W1202,W1300,W1301,W1302,W1303,W1304,W1305,W1306,W1307,W1401,W1402,W1501,W1503,W1645" +PYLINT_ENABLE="--enable R0401,W0101,W0102,W0104,W0105,W0106,W0107,W0108,W0109,W0111,W0120,W0122,W0123,W0124,W0125,W0150,W0199,W0211,W0222,W0232,W0233,W0301,W0312,W0401,W0404,W0406,W0410,W0601,W0602,W0603,W0604,W0611,W0612,W0614,W0622,W0623,W0640,W0711,W1201,W1202,W1300,W1301,W1302,W1303,W1304,W1305,W1306,W1307,W1401,W1402,W1501,W1503,W1645" if [ "$AVOCADO_PARALLEL_LINT" ]; then LINT_CMD="$LINT_CMD --parallel=$AVOCADO_PARALLEL_LINT" fi