134 lines
5.5 KiB
Diff
134 lines
5.5 KiB
Diff
From 42d772847f47068b0ad5b4cea0b8a90b7627ae79 Mon Sep 17 00:00:00 2001
|
|
From: John Kacur <jkacur@redhat.com>
|
|
Date: Wed, 6 May 2020 03:40:03 -0400
|
|
Subject: [PATCH 10/17] rteval: kcompile.py: Some style changes suggested by
|
|
pylint-3
|
|
|
|
Some style changes suggested by pylint-3
|
|
|
|
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
---
|
|
rteval/modules/loads/kcompile.py | 38 ++++++++++++++++----------------
|
|
1 file changed, 19 insertions(+), 19 deletions(-)
|
|
|
|
diff --git a/rteval/modules/loads/kcompile.py b/rteval/modules/loads/kcompile.py
|
|
index bba6d7be75e9..3973c2af6bce 100644
|
|
--- a/rteval/modules/loads/kcompile.py
|
|
+++ b/rteval/modules/loads/kcompile.py
|
|
@@ -29,12 +29,12 @@ from signal import SIGTERM
|
|
from rteval.modules import rtevalRuntimeError
|
|
from rteval.modules.loads import CommandLineLoad
|
|
from rteval.Log import Log
|
|
-from rteval.misc import expand_cpulist,compress_cpulist
|
|
+from rteval.misc import expand_cpulist, compress_cpulist
|
|
from rteval.systopology import SysTopology
|
|
|
|
-kernel_prefix="linux-5.1"
|
|
+kernel_prefix = "linux-5.1"
|
|
|
|
-class KBuildJob(object):
|
|
+class KBuildJob:
|
|
'''Class to manage a build job bound to a particular node'''
|
|
|
|
def __init__(self, node, kdir, logger=None, cpulist=None):
|
|
@@ -93,9 +93,9 @@ class KBuildJob(object):
|
|
stdin=sin, stdout=sout, stderr=serr)
|
|
|
|
def isrunning(self):
|
|
- if self.jobid == None:
|
|
+ if self.jobid is None:
|
|
return False
|
|
- return (self.jobid.poll() == None)
|
|
+ return self.jobid.poll() is None
|
|
|
|
def stop(self):
|
|
if not self.jobid:
|
|
@@ -113,7 +113,7 @@ class Kcompile(CommandLineLoad):
|
|
self.logger = logger
|
|
|
|
def _extract_tarball(self):
|
|
- if self.source == None:
|
|
+ if self.source is None:
|
|
raise rtevalRuntimeError(self, " no source tarball specified!")
|
|
self._log(Log.DEBUG, "unpacking kernel tarball")
|
|
tarargs = ['tar', '-C', self.builddir, '-x']
|
|
@@ -134,8 +134,8 @@ class Kcompile(CommandLineLoad):
|
|
return
|
|
self._log(Log.DEBUG, "removing kcompile directories in %s" % self.builddir)
|
|
null = os.open("/dev/null", os.O_RDWR)
|
|
- cmd=["rm", "-rf", os.path.join(self.builddir, "kernel*"), os.path.join(self.builddir, "node*")]
|
|
- ret = subprocess.call(cmd,stdin=null, stdout=null, stderr=null)
|
|
+ cmd = ["rm", "-rf", os.path.join(self.builddir, "kernel*"), os.path.join(self.builddir, "node*")]
|
|
+ ret = subprocess.call(cmd, stdin=null, stdout=null, stderr=null)
|
|
if ret:
|
|
raise rtevalRuntimeError(self, "error removing builddir (%s) (ret=%d)" % (self.builddir, ret))
|
|
|
|
@@ -154,21 +154,21 @@ class Kcompile(CommandLineLoad):
|
|
raise rtevalRuntimeError(self, " no kernel tarballs found in %s" % self.srcdir)
|
|
|
|
# check for existing directory
|
|
- kdir=None
|
|
- names=os.listdir(self.builddir)
|
|
+ kdir = None
|
|
+ names = os.listdir(self.builddir)
|
|
for d in names:
|
|
if d.startswith(kernel_prefix):
|
|
- kdir=d
|
|
+ kdir = d
|
|
break
|
|
- if kdir == None:
|
|
+ if kdir is None:
|
|
self._extract_tarball()
|
|
names = os.listdir(self.builddir)
|
|
for d in names:
|
|
self._log(Log.DEBUG, "checking %s" % d)
|
|
if d.startswith(kernel_prefix):
|
|
- kdir=d
|
|
+ kdir = d
|
|
break
|
|
- if kdir == None:
|
|
+ if kdir is None:
|
|
raise rtevalRuntimeError(self, "Can't find kernel directory!")
|
|
self.mydir = os.path.join(self.builddir, kdir)
|
|
self._log(Log.DEBUG, "mydir = %s" % self.mydir)
|
|
@@ -180,15 +180,15 @@ class Kcompile(CommandLineLoad):
|
|
self.cpus = {}
|
|
self.nodes = self.topology.getnodes()
|
|
for n in self.nodes:
|
|
- self.cpus[n] = [ int(c.split('/')[-1][3:]) for c in glob.glob('/sys/devices/system/node/node%s/cpu[0-9]*' % n) ]
|
|
+ self.cpus[n] = [int(c.split('/')[-1][3:]) for c in glob.glob('/sys/devices/system/node/node%s/cpu[0-9]*' % n)]
|
|
self.cpus[n].sort()
|
|
|
|
# if a cpulist was specified, only allow cpus in that list on the node
|
|
if self.cpulist:
|
|
- self.cpus[n] = [ c for c in self.cpus[n] if str(c) in expand_cpulist(self.cpulist) ]
|
|
+ self.cpus[n] = [c for c in self.cpus[n] if str(c) in expand_cpulist(self.cpulist)]
|
|
|
|
# remove nodes with no cpus available for running
|
|
- for node,cpus in self.cpus.items():
|
|
+ for node, cpus in self.cpus.items():
|
|
if not cpus:
|
|
self.nodes.remove(node)
|
|
self._log(Log.DEBUG, "node %s has no available cpus, removing" % node)
|
|
@@ -229,7 +229,7 @@ class Kcompile(CommandLineLoad):
|
|
os.close(err)
|
|
# clean up object dirs and make sure each has a config file
|
|
for n in self.nodes:
|
|
- self.buildjobs[n].clean(sin=null,sout=null,serr=null)
|
|
+ self.buildjobs[n].clean(sin=null, sout=null, serr=null)
|
|
os.close(null)
|
|
self._setReady()
|
|
|
|
@@ -277,7 +277,7 @@ class Kcompile(CommandLineLoad):
|
|
def _WorkloadCleanup(self):
|
|
self._log(Log.DEBUG, "out of stopevent loop")
|
|
for n in self.buildjobs:
|
|
- if self.buildjobs[n].jobid.poll() == None:
|
|
+ if self.buildjobs[n].jobid.poll() is None:
|
|
self._log(Log.DEBUG, "stopping job on node %d" % int(n))
|
|
self.buildjobs[n].jobid.terminate()
|
|
self.buildjobs[n].jobid.wait()
|
|
--
|
|
2.21.3
|
|
|