Blame SOURCES/tuna-tuna.py-use-fstrings.patch

e40fab
From 5f90d8b80a259884d3ca2a647fdf9471b7d7091c Mon Sep 17 00:00:00 2001
e40fab
From: Leah Leshchinsky <lleshchi@redhat.com>
e40fab
Date: Mon, 31 Oct 2022 13:15:07 -0400
e40fab
Subject: [PATCH 1/3] tuna: tuna.py use fstrings
e40fab
e40fab
Add fstrings where possible to improve readabilty
e40fab
e40fab
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
e40fab
Signed-off-by: John Kacur <jkacur@redhat.com>
e40fab
e40fab
diff --git a/tuna/tuna.py b/tuna/tuna.py
e40fab
index 84419c957b1b..e64211b88fc3 100755
e40fab
--- a/tuna/tuna.py
e40fab
+++ b/tuna/tuna.py
e40fab
@@ -58,7 +58,7 @@ def iskthread(pid):
e40fab
     # in this function, so that they know that the thread vanished and
e40fab
     # can act accordingly, removing entries from tree views, etc
e40fab
     try:
e40fab
-        f = open("/proc/%d/smaps" % pid)
e40fab
+        f = open(f"/proc/{pid}/smaps")
e40fab
     except IOError:
e40fab
         # Thread has vanished
e40fab
         return True
e40fab
@@ -88,7 +88,7 @@ def is_irq_thread(cmd):
e40fab
     return cmd[:4] in ("IRQ-", "irq/")
e40fab
 
e40fab
 def threaded_irq_re(irq):
e40fab
-    return re.compile("(irq/%s-.+|IRQ-%s)" % (irq, irq))
e40fab
+    return re.compile(f"(irq/{irq}-.+|IRQ-{irq})")
e40fab
 
e40fab
 # FIXME: Move to python-linux-procfs
e40fab
 def has_threaded_irqs(ps):
e40fab
@@ -96,10 +96,10 @@ def has_threaded_irqs(ps):
e40fab
     return len(ps.find_by_regex(irq_re)) > 0
e40fab
 
e40fab
 def set_irq_affinity_filename(filename, bitmasklist):
e40fab
-    pathname = "/proc/irq/%s" % filename
e40fab
+    pathname = f"/proc/irq/{filename}"
e40fab
     f = open(pathname, "w")
e40fab
     text = ",".join(["%x" % a for a in bitmasklist])
e40fab
-    f.write("%s\n" % text)
e40fab
+    f.write(f"{text}\n")
e40fab
     try:
e40fab
         f.close()
e40fab
     except IOError:
e40fab
@@ -225,7 +225,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning=None, spread=False)
e40fab
             if pid not in ps:
e40fab
                 continue
e40fab
 
e40fab
-            threads = procfs.pidstats("/proc/%d/task" % pid)
e40fab
+            threads = procfs.pidstats(f"/proc/{pid}/task")
e40fab
             for tid in list(threads.keys()):
e40fab
                 try:
e40fab
                     curr_affinity = os.sched_getaffinity(tid)
e40fab
@@ -320,11 +320,11 @@ def affinity_remove_cpus(affinity, cpus, nr_cpus):
e40fab
 # Should be moved to python_linux_procfs.interrupts, shared with interrupts.parse_affinity, etc.
e40fab
 def parse_irq_affinity_filename(filename, nr_cpus):
e40fab
     try:
e40fab
-        f = open("/proc/irq/%s" % filename)
e40fab
+        f = open(f"/proc/irq/{filename}")
e40fab
     except IOError as err:
e40fab
         if procfs.is_s390():
e40fab
             print("This operation is not supported on s390", file=sys.stderr)
e40fab
-            print("tuna: %s" % err, file=sys.stderr)
e40fab
+            print(f"tuna: {err}", file=sys.stderr)
e40fab
             sys.exit(2)
e40fab
 
e40fab
     line = f.readline()
e40fab
@@ -627,19 +627,19 @@ def run_command(cmd, policy, rtprio, cpu_list):
e40fab
             try:
e40fab
                 thread_set_priority(pid, policy, rtprio)
e40fab
             except (SystemError, OSError) as err:
e40fab
-                print("tuna: %s" % err)
e40fab
+                print(f"tuna: {err}")
e40fab
                 sys.exit(2)
e40fab
         if cpu_list:
e40fab
             try:
e40fab
                 os.sched_setaffinity(pid, cpu_list)
e40fab
             except (SystemError, OSError) as err:
e40fab
-                print("tuna: %s" % err)
e40fab
+                print(f"tuna: {err}")
e40fab
                 sys.exit(2)
e40fab
 
e40fab
         try:
e40fab
             os.execvp(cmd_list[0], cmd_list)
e40fab
         except (SystemError, OSError) as err:
e40fab
-            print("tuna: %s" % err)
e40fab
+            print(f"tuna: {err}")
e40fab
             sys.exit(2)
e40fab
     else:
e40fab
         os.waitpid(newpid, 0)
e40fab
-- 
e40fab
2.31.1
e40fab