Skip to content

Commit bf0c24f

Browse files
committed
chore: replace percent strings for logging
This replaces logging with their best counterpart. Either normal logging methods with arguments, or by utilizing `.format()`
1 parent 060f4f6 commit bf0c24f

File tree

9 files changed

+31
-28
lines changed

9 files changed

+31
-28
lines changed

convert2rhel/actions/system_checks/is_loaded_kernel_latest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ def run(self):
3939

4040
if system_info.id == "oracle" and system_info.eus_system:
4141
logger.info(
42-
"Did not perform the check because there were no publicly available %s %d.%d repositories available."
43-
% (system_info.name, system_info.version.major, system_info.version.minor)
42+
"Did not perform the check because there were no publicly available %s %d.%d repositories available.",
43+
system_info.name,
44+
system_info.version.major,
45+
system_info.version.minor,
4446
)
4547
return
4648

convert2rhel/actions/system_checks/package_updates.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,19 @@ def run(self):
3535

3636
if system_info.id == "oracle" and system_info.eus_system:
3737
logger.info(
38-
"Did not perform the check because there were no publicly available %s %d.%d repositories available."
39-
% (system_info.name, system_info.version.major, system_info.version.minor)
38+
"Did not perform the check because there were no publicly available {} {}.{} repositories available.".format(
39+
system_info.name, system_info.version.major, system_info.version.minor
40+
)
4041
)
4142
self.add_message(
4243
level="INFO",
4344
id="PACKAGE_UPDATES_CHECK_SKIP_NO_PUBLIC_REPOSITORIES",
4445
title="Did not perform the package updates check",
4546
description="Please refer to the diagnosis for further information",
4647
diagnosis=(
47-
"Did not perform the check because there were no publicly available %s %d.%d repositories available."
48-
% (system_info.name, system_info.version.major, system_info.version.minor)
48+
"Did not perform the check because there were no publicly available {} {}.{} repositories available.".format(
49+
system_info.name, system_info.version.major, system_info.version.minor
50+
)
4951
),
5052
)
5153
return

convert2rhel/actions/system_checks/rhel_compatible_kernel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ def _bad_kernel_version(kernel_release):
116116
)
117117

118118
logger.debug(
119-
"Booted kernel version '%s' corresponds to the version available in RHEL %d"
120-
% (kernel_version, system_info.version.major)
119+
"Booted kernel version '{}' corresponds to the version available in RHEL {}".format(
120+
kernel_version, system_info.version.major
121+
)
121122
)
122123
return False
123124

convert2rhel/applock.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __str__(self):
7272
status = "locked"
7373
else:
7474
status = "unlocked"
75-
return "%s PID %d %s" % (self._pidfile, self._pid, status)
75+
return "{} PID {} {}".format(self._pidfile, self._pid, status)
7676

7777
def _try_create(self):
7878
"""Try to create the lock file. If this succeeds, the lock file
@@ -149,10 +149,10 @@ def try_to_lock(self, _recursive=False):
149149
raise ApplicationLockedError("Lock file {} is corrupt".format(self._pidfile))
150150

151151
if self._pid_exists(pid):
152-
raise ApplicationLockedError("%s locked by process %d" % (self._pidfile, pid))
152+
raise ApplicationLockedError("{} locked by process {}".format(self._pidfile, pid))
153153
# The lock file was created by a process that has exited;
154154
# remove it and try again.
155-
logger.info("Cleaning up lock held by exited process %d." % pid)
155+
logger.info("Cleaning up lock held by exited process %d.", pid)
156156
os.unlink(self._pidfile)
157157
self.try_to_lock(_recursive=True)
158158

convert2rhel/backup/packages.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ def _install_local_rpms(self, replace=False, critical=True):
172172
"one or more packages that we removed as part of the "
173173
"conversion."
174174
),
175-
diagnosis="Couldn't install %s packages. Command: %s Output: %s Status: %d"
176-
% (pkgs_as_str, cmd, output, ret_code),
175+
diagnosis="Couldn't install {} packages. Command: {} Output: {} Status: {}".format(
176+
pkgs_as_str, cmd, output, ret_code
177+
),
177178
)
178179

179180
logger.warning("Couldn't install {} packages.".format(pkgs_as_str))

convert2rhel/pkghandler.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,7 @@ def format_pkg_info(pkgs, disable_repos=None):
318318
max_nvra_length = max(len(nvra) for nvra in package_info)
319319

320320
header = (
321-
"%-*s %-*s %s"
322-
% (
321+
"{}-{} {}-{} {}".format(
323322
max_nvra_length,
324323
"Package",
325324
max_packager_length,
@@ -329,8 +328,7 @@ def format_pkg_info(pkgs, disable_repos=None):
329328
+ "\n"
330329
)
331330
header_underline = (
332-
"%-*s %-*s %s"
333-
% (
331+
"{}-{} {}-{} {}".format(
334332
max_nvra_length,
335333
"-" * len("Package"),
336334
max_packager_length,
@@ -348,8 +346,7 @@ def format_pkg_info(pkgs, disable_repos=None):
348346
pkg_list = ""
349347
for package, info in package_info.items():
350348
pkg_list += (
351-
"%-*s %-*s %s"
352-
% (
349+
"{}-{} {}-{} {}".format(
353350
max_nvra_length,
354351
package,
355352
max_packager_length,

convert2rhel/pkgmanager/handlers/dnf/callback.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def end(self, payload, status, err_msg):
196196
if status:
197197
# the error message, no trimming
198198
if status == pkgmanager.callback.STATUS_DRPM and self.total_drpm > 1:
199-
message = "(%d/%d) [%s %d/%d]: %s" % (
199+
message = "({}/{}) [{} {}/{}]: {}".format(
200200
self.done_files,
201201
self.total_files,
202202
self._STATUS_MAPPING[status],
@@ -206,15 +206,15 @@ def end(self, payload, status, err_msg):
206206
)
207207
message = "{} - {}".format(message, err_msg)
208208
else:
209-
message = "(%d/%d) [%s]: %s" % (
209+
message = "({}/{}) [{}]: {}".format(
210210
self.done_files,
211211
self.total_files,
212212
self._STATUS_MAPPING.get(status, "Unknown"),
213213
package,
214214
)
215215
else:
216216
if self.total_files > 1:
217-
message = "(%d/%d): %s" % (self.done_files, self.total_files, package)
217+
message = "({}/{}): {}".format(self.done_files, self.total_files, package)
218218

219219
if message:
220220
logger.info(message)

convert2rhel/subscription.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def register_system():
155155
while attempt < MAX_NUM_OF_ATTEMPTS_TO_SUBSCRIBE:
156156
attempt_msg = ""
157157
if attempt > 0:
158-
attempt_msg = "Attempt %d of %d: " % (
158+
attempt_msg = "Attempt {} of {}: ".format(
159159
attempt + 1,
160160
MAX_NUM_OF_ATTEMPTS_TO_SUBSCRIBE,
161161
)

convert2rhel/systeminfo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ def resolve_system_info(self):
182182

183183
def print_system_information(self):
184184
"""Print system related information."""
185-
self.logger.info("%-20s %s" % ("Name:", self.name))
186-
self.logger.info("%-20s %s" % ("OS version:", self.version))
187-
self.logger.info("%-20s %s" % ("Architecture:", self.arch))
188-
self.logger.info("%-20s %s" % ("Config filename:", self.cfg_filename))
185+
self.logger.info("%-20s %s", "Name:", self.name)
186+
self.logger.info("%-20s %s", "OS version:", self.version)
187+
self.logger.info("%-20s %s", "Architecture:", self.arch)
188+
self.logger.info("%-20s %s", "Config filename:", self.cfg_filename)
189189

190190
@staticmethod
191191
def get_system_release_file_content():
@@ -282,7 +282,7 @@ def _get_architecture(self):
282282
return arch
283283

284284
def _get_cfg_filename(self):
285-
cfg_filename = "%s-%d-%s.cfg" % (
285+
cfg_filename = "{}-{}-{}.cfg".format(
286286
self.id,
287287
self.version.major,
288288
self.arch,

0 commit comments

Comments
 (0)