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

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