* [PATCH] rt-tests: hwlatdetect.py: Code clean-up
@ 2019-05-10 14:01 John Kacur
2019-05-13 22:06 ` Clark Williams
0 siblings, 1 reply; 2+ messages in thread
From: John Kacur @ 2019-05-10 14:01 UTC (permalink / raw)
To: rt-users; +Cc: Clark Williams, John Kacur
- Remove obsolete from __future__
- Fix spacing around calls to print, open and brackets
- Fix spacing around assignments
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/hwlatdetect/hwlatdetect.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 368079a158b1..b72bdc3aa930 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -8,7 +8,7 @@
# modify it under the terms of the GNU General Public License Version 2
# as published by the Free Software Foundation.
-from __future__ import print_function
+
import sys
import os
@@ -84,7 +84,7 @@ class DebugFS(object):
try:
val = f.readline()
except OSError as e:
- print ("errno: %s" % e)
+ print("errno: %s" % e)
if e.errno == errno.EAGAIN:
val = None
else:
@@ -159,7 +159,7 @@ class Kmod(object):
return
# now look for already loaded module
- for l in open ('/proc/modules'):
+ for l in open('/proc/modules'):
field = l.split()
if self.name in field[0]:
self.preloaded = True
@@ -210,7 +210,7 @@ class Detector(object):
if self.have_msr:
p = subprocess.Popen(['/usr/sbin/rdmsr', '-a', '-d', '0x34'], stdout=subprocess.PIPE)
p.wait()
- counts = [ int(x.strip()) for x in p.stdout.readlines()]
+ counts = [int(x.strip()) for x in p.stdout.readlines()]
return counts
# methods for preventing/enabling c-state transitions
@@ -295,11 +295,11 @@ class Tracer(Detector):
class Sample(object):
'private class for tracer sample data'
- __slots__= 'timestamp', 'inner', 'outer',
+ __slots__ = 'timestamp', 'inner', 'outer',
def __init__(self, line):
fields = line.split()
i,o = fields[6].split('/')
- ts=fields[7][3:]
+ ts = fields[7][3:]
self.timestamp = str(ts)
self.inner = int(i)
self.outer = int(o)
@@ -332,14 +332,14 @@ class Tracer(Detector):
self.set('current_tracer', 'hwlat')
def set(self, field, val):
- path=self.translate(field)
+ path = self.translate(field)
self.debugfs.putval(path, str(val))
def get(self, field):
if field == "count":
return len(self.samples)
elif field == "max":
- max=0
+ max = 0
for values in self.samples:
s = int(values.largest())
if s > max:
@@ -435,7 +435,7 @@ class Hwlat(Detector):
def display(self):
for s in self.samples:
- print (s)
+ print(s)
def save(self, output=None):
if output:
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rt-tests: hwlatdetect.py: Code clean-up
2019-05-10 14:01 [PATCH] rt-tests: hwlatdetect.py: Code clean-up John Kacur
@ 2019-05-13 22:06 ` Clark Williams
0 siblings, 0 replies; 2+ messages in thread
From: Clark Williams @ 2019-05-13 22:06 UTC (permalink / raw)
To: John Kacur; +Cc: rt-users
On Fri, 10 May 2019 16:01:44 +0200
John Kacur <jkacur@redhat.com> wrote:
> - Remove obsolete from __future__
> - Fix spacing around calls to print, open and brackets
> - Fix spacing around assignments
>
> Signed-off-by: John Kacur <jkacur@redhat.com>
> ---
> src/hwlatdetect/hwlatdetect.py | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
> index 368079a158b1..b72bdc3aa930 100755
> --- a/src/hwlatdetect/hwlatdetect.py
> +++ b/src/hwlatdetect/hwlatdetect.py
> @@ -8,7 +8,7 @@
> # modify it under the terms of the GNU General Public License Version 2
> # as published by the Free Software Foundation.
>
> -from __future__ import print_function
> +
>
> import sys
> import os
> @@ -84,7 +84,7 @@ class DebugFS(object):
> try:
> val = f.readline()
> except OSError as e:
> - print ("errno: %s" % e)
> + print("errno: %s" % e)
> if e.errno == errno.EAGAIN:
> val = None
> else:
> @@ -159,7 +159,7 @@ class Kmod(object):
> return
>
> # now look for already loaded module
> - for l in open ('/proc/modules'):
> + for l in open('/proc/modules'):
> field = l.split()
> if self.name in field[0]:
> self.preloaded = True
> @@ -210,7 +210,7 @@ class Detector(object):
> if self.have_msr:
> p = subprocess.Popen(['/usr/sbin/rdmsr', '-a', '-d', '0x34'], stdout=subprocess.PIPE)
> p.wait()
> - counts = [ int(x.strip()) for x in p.stdout.readlines()]
> + counts = [int(x.strip()) for x in p.stdout.readlines()]
> return counts
>
> # methods for preventing/enabling c-state transitions
> @@ -295,11 +295,11 @@ class Tracer(Detector):
>
> class Sample(object):
> 'private class for tracer sample data'
> - __slots__= 'timestamp', 'inner', 'outer',
> + __slots__ = 'timestamp', 'inner', 'outer',
> def __init__(self, line):
> fields = line.split()
> i,o = fields[6].split('/')
> - ts=fields[7][3:]
> + ts = fields[7][3:]
> self.timestamp = str(ts)
> self.inner = int(i)
> self.outer = int(o)
> @@ -332,14 +332,14 @@ class Tracer(Detector):
> self.set('current_tracer', 'hwlat')
>
> def set(self, field, val):
> - path=self.translate(field)
> + path = self.translate(field)
> self.debugfs.putval(path, str(val))
>
> def get(self, field):
> if field == "count":
> return len(self.samples)
> elif field == "max":
> - max=0
> + max = 0
> for values in self.samples:
> s = int(values.largest())
> if s > max:
> @@ -435,7 +435,7 @@ class Hwlat(Detector):
>
> def display(self):
> for s in self.samples:
> - print (s)
> + print(s)
>
> def save(self, output=None):
> if output:
> --
> 2.20.1
>
Acked-by: Clark Williams <williams@redhat.com>
--
The United States Coast Guard
Ruining Natural Selection since 1790
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-13 22:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 14:01 [PATCH] rt-tests: hwlatdetect.py: Code clean-up John Kacur
2019-05-13 22:06 ` Clark Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).