Skip to content

Commit

Permalink
Merge pull request #3798 from clumens/f-strings
Browse files Browse the repository at this point in the history
Refactor: python: Convert to using f-strings in the python module.
  • Loading branch information
clumens authored Jan 15, 2025
2 parents 7dc494a + 9d1bb14 commit 47b8613
Show file tree
Hide file tree
Showing 39 changed files with 535 additions and 551 deletions.
20 changes: 10 additions & 10 deletions python/pacemaker/_cts/CTS.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Main classes for Pacemaker's Cluster Test Suite (CTS)."""

__all__ = ["CtsLab", "NodeStatus", "Process"]
__copyright__ = "Copyright 2000-2024 the Pacemaker project contributors"
__copyright__ = "Copyright 2000-2025 the Pacemaker project contributors"
__license__ = "GNU General Public License version 2 or later (GPLv2+) WITHOUT ANY WARRANTY"

import sys
Expand Down Expand Up @@ -85,7 +85,7 @@ def run(self, scenario, iterations):
self._logger.log("Cluster nodes: ")
# pylint: disable=unsubscriptable-object
for node in self._env["nodes"]:
self._logger.log(" * %s" % (node))
self._logger.log(f" * {node}")

if not scenario.setup():
return ExitStatus.ERROR
Expand All @@ -96,7 +96,7 @@ def run(self, scenario, iterations):
try:
scenario.run(iterations)
except: # noqa: E722
self._logger.log("Exception by %s" % sys.exc_info()[0])
self._logger.log(f"Exception by {sys.exc_info()[0]}")
self._logger.traceback(traceback)

scenario.summarize()
Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(self, env):
def _node_booted(self, node):
"""Return True if the given node is booted (responds to pings)."""
# pylint: disable=not-callable
(rc, _) = RemoteFactory().getInstance()("localhost", "ping -nq -c1 -w1 %s" % node, verbose=0)
(rc, _) = RemoteFactory().getInstance()("localhost", f"ping -nq -c1 -w1 {node}", verbose=0)
return rc == 0

def _sshd_up(self, node):
Expand All @@ -162,20 +162,20 @@ def wait_for_node(self, node, timeout=300):
if anytimeouts:
# Fudge to wait for the system to finish coming up
time.sleep(30)
LogFactory().debug("Node %s now up" % node)
LogFactory().debug(f"Node {node} now up")

return True

time.sleep(30)
if not anytimeouts:
LogFactory().debug("Waiting for node %s to come up" % node)
LogFactory().debug(f"Waiting for node {node} to come up")

anytimeouts = True
timeout -= 1

LogFactory().log("%s did not come up within %d tries" % (node, initial_timeout))
LogFactory().log(f"{node} did not come up within {initial_timeout} tries")
if not should_continue(self._env["continue"]):
raise ValueError("%s did not come up within %d tries" % (node, initial_timeout))
raise ValueError(f"{node} did not come up within {initial_timeout} tries")

return False

Expand Down Expand Up @@ -224,7 +224,7 @@ def __init__(self, cm, name, dc_only=False, pats=None, dc_pats=None,

def kill(self, node):
"""Kill the instance of this process running on the given node."""
(rc, _) = self._cm.rsh(node, "killall -9 %s" % self.name)
(rc, _) = self._cm.rsh(node, f"killall -9 {self.name}")

if rc != 0:
self._cm.log("ERROR: Kill %s failed on node %s" % (self.name, node))
self._cm.log(f"ERROR: Kill {self.name} failed on node {node}")
Loading

0 comments on commit 47b8613

Please sign in to comment.