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

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