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

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