From: John Kacur <jkacur@redhat.com>
To: Leah Leshchinsky <lleshchi@redhat.com>
Cc: linux-rt-users@vger.kernel.org
Subject: Re: [PATCH] rt-tests: hwlatdetect.py Covert to f-strings
Date: Wed, 2 Nov 2022 16:30:18 -0400 (EDT) [thread overview]
Message-ID: <f624d8c-3865-2cb-d030-a8c20f46d9a@redhat.com> (raw)
In-Reply-To: <20221102143554.214241-1-lleshchi@redhat.com>
On Wed, 2 Nov 2022, Leah Leshchinsky wrote:
> Add f-strings where applicable for readability.
>
> Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
>
> diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
> index 9ef50f862127..3b20f664a536 100755
> --- a/src/hwlatdetect/hwlatdetect.py
> +++ b/src/hwlatdetect/hwlatdetect.py
> @@ -59,7 +59,7 @@ class DebugFS:
> if self.premounted or self.mounted:
> debug("not mounting debugfs")
> return True
> - debug("mounting debugfs at %s" % path)
> + debug(f"mounting debugfs at {path}")
> self.mountpoint = path
> cmd = ['/bin/mount', '-t', 'debugfs', 'none', path]
> self.mounted = (subprocess.call(cmd) == 0)
> @@ -90,7 +90,7 @@ class DebugFS:
> try:
> val = f.readline()
> except OSError as e:
> - print("errno: %s" % e)
> + print(f"errno: {e}")
> if e.errno == errno.EAGAIN:
> val = None
> else:
> @@ -192,13 +192,13 @@ class Detector:
> count = 0
> threshold = int(self.get("threshold"))
> self.c_states_off()
> - debug("enabling detector module (threshold: %d)" % threshold)
> + debug(f"enabling detector module (threshold: {threshold})")
> self.set("enable", 1)
> while self.get("enable") == 0:
> debug("still disabled, retrying in a bit")
> count += 1
> time.sleep(0.1)
> - debug("retrying enable of detector module (%d)" % count)
> + debug(f"retrying enable of detector module ({count})")
> self.set("enable", 1)
> if self.get("threshold") != threshold:
> debug("start: threshold reset by start, fixing")
> @@ -214,7 +214,7 @@ class Detector:
> debug("still enabled, retrying in a bit")
> count += 1
> time.sleep(0.1)
> - debug("retrying disable of detector module(%d)" % count)
> + debug(f"retrying disable of detector module({count})")
> self.set("enable", 0)
> self.c_states_on()
> debug("detector module disabled")
> @@ -248,7 +248,7 @@ class Tracer(Detector):
> self.outer = int(o)
>
> def __str__(self):
> - return "ts: %s, inner:%d, outer:%d" % (self.timestamp, self.inner, self.outer)
> + return f"ts: {self.timestamp}, inner:{self.inner}, outer:{self.outer}"
>
> def display(self):
> """ convert object to string and print """
> @@ -352,7 +352,7 @@ def seconds(sval):
> return int(sval[0:-1]) * 86400
> if sval[-1:] == 'w':
> return int(sval[0:-1]) * 86400 * 7
> - raise RuntimeError("invalid input for seconds: '%s'" % sval)
> + raise RuntimeError(f"invalid input for seconds: '{sval}'")
>
>
> def milliseconds(sval):
> @@ -367,7 +367,7 @@ def milliseconds(sval):
> return int(sval[0:-1]) * 1000 * 60
> if sval[-1] == 'h':
> return int(sval[0:-1]) * 1000 * 60 * 60
> - raise RuntimeError("invalid input for milliseconds: %s" % sval)
> + raise RuntimeError(f"invalid input for milliseconds: {sval}")
>
>
> def microseconds(sval):
> @@ -380,7 +380,7 @@ def microseconds(sval):
> return int(sval[0:-2])
> if sval[-1:] == 's':
> return int(sval[0:-1]) * 1000 * 1000
> - raise RuntimeError("invalid input for microseconds: '%s'" % sval)
> + raise RuntimeError(f"invalid input for microseconds: '{sval}'")
>
>
> if __name__ == '__main__':
> @@ -518,7 +518,7 @@ if __name__ == '__main__':
> info("Samples recorded: %d" % len(detect.samples))
>
> exceeding = detect.get("count")
> - info("Samples exceeding threshold: %d" % exceeding)
> + info(f"Samples exceeding threshold: {exceeding}")
>
> if detect.have_msr:
> finishsmi = detect.getsmicounts()
> @@ -527,8 +527,8 @@ if __name__ == '__main__':
> if count > detect.initsmi[i]:
> smis = count - detect.initsmi[i]
> total_smis += smis
> - print("%d SMIs occured on cpu %d" % (smis, i))
> - info("SMIs during run: %d" % total_smis)
> + print(f"{smis} SMIs occured on cpu {i}")
> + info(f"SMIs during run: {total_smis}")
>
> maxlatency = int(detect.get("max"))
>
> --
This looks fine, but there are others that could be converted too.
Signed-off-by: John Kacur <jkacur@redhat.com>
prev parent reply other threads:[~2022-11-02 20:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 14:35 [PATCH] rt-tests: hwlatdetect.py Covert to f-strings Leah Leshchinsky
2022-11-02 20:30 ` John Kacur [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f624d8c-3865-2cb-d030-a8c20f46d9a@redhat.com \
--to=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=lleshchi@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox