[PATCH] tuna: Fix string syntax warnings with raw strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tuna save <filename> allows you to save your kthreads tunables to
a file to be used by rtctl. There were several backslashes that produce
an error that pylint and Python (at least 3.12) gives a `SyntaxWarning:
invalid escape sequence`.

Convert the strings written to the file with raw strings to resolve the
warnings.

Tested by comparing the diffs of the files outputted by save.

Signed-off-by: John B. Wyatt IV <jwyatt@xxxxxxxxxx>
Signed-off-by: John B. Wyatt IV <sageofredondo@xxxxxxxxx>
---
 tuna/tuna.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tuna/tuna.py b/tuna/tuna.py
index bd678e2..2dbc6cb 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -669,7 +669,8 @@ def generate_rtgroups(filename, kthreads, nr_cpus):
 # The regex is matched against process names as printed by "ps -eo cmd".
 
 ''' % filename)
-    f.write("kthreads:*:1:*:\[.*\]$\n\n")
+    f.write(r"kthreads:*:1:*:\[.*\]$")
+    f.write("\n\n")
 
     per_cpu_kthreads = []
     names = list(kthreads.keys())
@@ -688,7 +689,7 @@ def generate_rtgroups(filename, kthreads, nr_cpus):
             elif common[:8] == "softirq-":
                 common = "(sirq|softirq)" + common[7:]
                 name = "s" + name[4:]
-            regex = common + "\/.*"
+            regex = common + r"\/.*"
         except:
             idx = 0
             regex = name
@@ -701,9 +702,10 @@ def generate_rtgroups(filename, kthreads, nr_cpus):
         else:
             mask = ",".join([hex(a) for a in \
                      procfs.hexbitmask(kt.affinity, nr_cpus)])
-        f.write("%s:%c:%d:%s:\[%s\]$\n" % (name, \
+        f.write(r"%s:%c:%d:%s:\[%s\]$" % (name, \
                            tuna_sched.sched_str(kt.policy)[6].lower(), \
                             kt.rtprio, mask, regex))
+        f.write("\n")
     f.close()
 
 
-- 
2.47.0





[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux