Skip to content

Commit

Permalink
sweep: DIRACGrid#7614 fix for pylint 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed May 15, 2024
1 parent 76d15cf commit ae48623
Show file tree
Hide file tree
Showing 39 changed files with 71 additions and 2,226 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ def _printDiff(self, entry, level=""):
diffType, entryName, _value, changes, _comment = entry
elif len(entry) == 4:
diffType, entryName, _value, changes = entry
else:
raise ValueError(f"Invalid entry {entry}")

fullPath = os.path.join(level, entryName)

Expand Down
5 changes: 3 additions & 2 deletions src/DIRAC/Core/Base/AgentModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,10 @@ def am_go(self):
elapsedTime = time.time()
if self.activityMonitoring:
initialWallTime, initialCPUTime, mem = self._startReportToMonitoring()
cycleResult = self.__executeModuleCycle()
if self.activityMonitoring and initialWallTime and initialCPUTime:
cycleResult = self.__executeModuleCycle()
cpuPercentage = self._endReportToMonitoring(initialWallTime, initialCPUTime)
else:
cycleResult = self.__executeModuleCycle()
# Increment counters
self.__moduleProperties["cyclesDone"] += 1
# Show status
Expand Down
2 changes: 2 additions & 0 deletions src/DIRAC/Core/DISET/ServiceReactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
must inherit from the base class RequestHandler
"""

import time
import datetime
import selectors
Expand Down Expand Up @@ -200,6 +201,7 @@ def __acceptIncomingConnection(self, svcName=False):
"""
sel = self.__getListeningSelector(svcName)
while self.__alive:
clientTransport = None
try:
events = sel.select(timeout=10)
if len(events) == 0:
Expand Down
3 changes: 3 additions & 0 deletions src/DIRAC/Core/Security/VOMS.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" Module for dealing with VOMS (Virtual Organization Membership Service)
"""

from datetime import datetime
import os
import tempfile
Expand Down Expand Up @@ -117,6 +118,8 @@ def getVOMSAttributes(self, proxy, switch="all"):
returnValue = nickName
elif switch == "all":
returnValue = attributes
else:
raise NotImplementedError(switch)

return S_OK(returnValue)

Expand Down
1 change: 1 addition & 0 deletions src/DIRAC/Core/Utilities/ElasticSearchDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ def generateFullIndexName(indexName, period):

# Do NOT use datetime.today() because it is not UTC
todayUTC = datetime.utcnow().date()
suffix = None

if period.lower() == "day":
suffix = todayUTC.strftime("%Y-%m-%d")
Expand Down
3 changes: 2 additions & 1 deletion src/DIRAC/Core/Utilities/Graphs/Graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Graph:

def layoutFigure(self, legend):
prefs = self.prefs
nsublines = left = bottom = None

# Get the main Figure object
# self.figure = Figure()
Expand Down Expand Up @@ -182,7 +183,7 @@ def makeTextGraph(self, text="Empty image"):

def makeGraph(self, data, *args, **kw):
start = time.time()

plot_type = None
# Evaluate all the preferences
self.prefs = evalPrefs(*args, **kw)
prefs = self.prefs
Expand Down
1 change: 1 addition & 0 deletions src/DIRAC/Core/Utilities/Graphs/GraphUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def add_time_to_title(begin, end, metadata={}):
representing 168 Hours, but needed the format to show the date as
well as the time.
"""
format_str = None
if "span" in metadata:
interval = metadata["span"]
else:
Expand Down
2 changes: 2 additions & 0 deletions src/DIRAC/Core/Utilities/Graphs/Legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The DIRAC Graphs package is derived from the GraphTool plotting package of the
CMS/Phedex Project by ... <to be added>
"""

from matplotlib.patches import Rectangle
from matplotlib.text import Text
from matplotlib.figure import Figure
Expand Down Expand Up @@ -63,6 +64,7 @@ def getLegendSize(self):
legend_padding = float(self.prefs["legend_padding"])
legend_text_size = self.prefs.get("legend_text_size", self.prefs["text_size"])
legend_text_padding = self.prefs.get("legend_text_padding", self.prefs["text_padding"])
legend_max_height = -1
if legend_position in ["right", "left"]:
# One column in case of vertical legend
legend_width = self.column_width + legend_padding
Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The DIRAC Graphs package is derived from the GraphTool plotting package of the
CMS/Phedex Project by ... <to be added>
"""

import datetime
from pylab import setp
from matplotlib.colors import Normalize
Expand Down Expand Up @@ -39,7 +40,6 @@


class QualityMapGraph(PlotBase):

"""
The BarGraph class is a straightforward bar graph; given a dictionary
of values, it takes the keys as the independent variable and the values
Expand Down Expand Up @@ -167,7 +167,7 @@ def draw(self):
setp(self.ax.get_xticklines(), markersize=0.0) # pylint: disable=not-callable
setp(self.ax.get_yticklines(), markersize=0.0) # pylint: disable=not-callable

cax, kw = make_axes(self.ax, orientation="vertical", fraction=0.07)
cax, _kw = make_axes(self.ax, orientation="vertical", fraction=0.07) # pylint: disable=unpacking-non-sequence
# ColorbarBase is used to generate the colors within the legend at the right of the plot
ColorbarBase(
cax, cmap=self.cmap, norm=self.norms, boundaries=self.cbBoundaries, values=self.cbValues, ticks=self.cbTicks
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Core/Utilities/Graphs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
def graph(data, fileName, *args, **kw):
prefs = evalPrefs(*args, **kw)
graph_size = prefs.get("graph_size", "normal")

defaults = None
if graph_size == "normal":
defaults = graph_normal_prefs
elif graph_size == "small":
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Core/Utilities/MySQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ def buildCondition(
"""
condition = ""
conjunction = "WHERE"

attrName = None
if condDict is not None:
for aName, attrValue in condDict.items():
if isinstance(aName, str):
Expand Down
5 changes: 5 additions & 0 deletions src/DIRAC/DataManagementSystem/Client/DataManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
This module consists of DataManager and related classes.
"""

# # imports
from datetime import datetime, timedelta
import fnmatch
Expand Down Expand Up @@ -988,6 +989,8 @@ def registerFile(self, fileTuple, catalog=""):
fileTuples = fileTuple
elif isinstance(fileTuple, tuple):
fileTuples = [fileTuple]
else:
return S_ERROR(f"fileTuple is none of list,set,tuple: {type(fileTuple)}")
for fileTuple in fileTuples:
if not isinstance(fileTuple, tuple):
errStr = "Supplied file info must be tuple or list of tuples."
Expand Down Expand Up @@ -1041,6 +1044,8 @@ def registerReplica(self, replicaTuple, catalog=""):
replicaTuples = replicaTuple
elif isinstance(replicaTuple, tuple):
replicaTuples = [replicaTuple]
else:
return S_ERROR(f"replicaTuple is not of type list,set or tuple: {type(replicaTuple)}")
for replicaTuple in replicaTuples:
if not isinstance(replicaTuple, tuple):
errStr = "Supplied file info must be tuple or list of tuples."
Expand Down
1 change: 1 addition & 0 deletions src/DIRAC/DataManagementSystem/Client/DirectoryListing.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def addDirectory(self, name, dirDict, numericid):
date = dirDict["ModificationDate"]
nlinks = 0
size = 0
gname = None
if "Owner" in dirDict:
uname = dirDict["Owner"]
elif "OwnerDN" in dirDict:
Expand Down
5 changes: 2 additions & 3 deletions src/DIRAC/DataManagementSystem/Client/FileCatalogClientCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,8 @@ def do_ancestorset(self, args):
def complete_ancestorset(self, text, line, begidx, endidx):
args = line.split()

if len(args) == 1:
cur_path = ""
elif len(args) > 1:
cur_path = ""
if len(args) > 1:
# If the line ends with ' '
# this means a new parameter begin.
if line.endswith(" "):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,12 @@ def export_createDirectory(self, dir_path):
def export_listDirectory(self, dir_path, mode):
"""Return the dir_path directory listing"""
is_file = False
fname = None
dirList = None
path = self.__resolveFileID(dir_path)
if not os.path.exists(path):
return S_ERROR(f"Directory {dir_path} does not exist")
elif os.path.isfile(path):
if os.path.isfile(path):
fname = os.path.basename(path)
is_file = True
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ def do_install(self, args):
install executor <system> <executor> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
"""
argss = args.split()
hostSetup = extension = None
if not argss:
gLogger.notice(self.do_install.__doc__)
return
Expand Down
2 changes: 2 additions & 0 deletions src/DIRAC/FrameworkSystem/Service/BundleDeliveryHandler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" Handler for CAs + CRLs bundles
"""

import io
import os
import tarfile
Expand Down Expand Up @@ -91,6 +92,7 @@ def transfer_toClient(self, fileId, _token, fileHelper):
self.bundleManager.updateBundles()

version = ""
bId = None
if isinstance(fileId, str):
if fileId in ["CAs", "CRLs"]:
return self.__transferFile(fileId, fileHelper)
Expand Down
5 changes: 2 additions & 3 deletions src/DIRAC/Interfaces/scripts/dirac_admin_get_banned_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ def main():
diracAdmin = DiracAdmin()

result = diracAdmin.getBannedSites()
if result["OK"]:
bannedSites = result["Value"]
else:
if not result["OK"]:
gLogger.error(result["Message"])
DIRACExit(2)

bannedSites = result["Value"]
for site in bannedSites:
result = diracAdmin.getSiteMaskLogging(site, printOutput=True)
if not result["OK"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@ def main():
jobGroup=jobGroup,
date=date,
)
if result["OK"]:
jobs = result["Value"]
else:
if not result["OK"]:
print("Error in selectJob", result["Message"])
DIRAC.exit(2)

jobs = result["Value"]
for job in jobs:
result = dirac.getOutputSandbox(job)
if result["OK"]:
Expand Down
1 change: 1 addition & 0 deletions src/DIRAC/Interfaces/scripts/dmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def getListIndex(self):
else:
fdType = "-" + params.getIndex()
for arg in args:
rtype = None
meta, mtype = arg.split("=")
if mtype.lower()[:3] == "int":
rtype = "INT"
Expand Down
6 changes: 4 additions & 2 deletions src/DIRAC/ProductionSystem/Utilities/ProdTransManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ def deleteProductionTransformations(self, prodID):
:param int prodID: the ProductionID
"""
res = self.prodClient.getProductionTransformations(prodID)
if res["OK"]:
transList = res["Value"]
if not res["OK"]:
return res

transList = res["Value"]

gLogger.notice(f"Deleting production transformations {transList} from the TS")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def main():
prodID = args[0]
res = prodClient.getProduction(prodID)

if res["OK"]:
prod = res["Value"]
else:
if not res["OK"]:
DIRAC.gLogger.error(res["Message"])
DIRAC.exit(-1)

prod = res["Value"]

print(f"Description for production {prodID}:\n")
print(prod["Description"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ def validate(cls, request):
@classmethod
def export_getRequestIDForName(cls, requestName):
"""get requestID for given :requestName:"""
if isinstance(requestName, str):
result = cls.__requestDB.getRequestIDForName(requestName)
if not result["OK"]:
return result
requestID = result["Value"]
return S_OK(requestID)

return cls.__requestDB.getRequestIDForName(requestName)

types_cancelRequest = [int]

Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/ResourceStatusSystem/Client/ResourceStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __getCSElementStatus(self, elementName, elementType, statusType, default):
:param default: defult value
:type default: None, str
"""

cs_path = None
# DIRAC doesn't store the status of ComputingElements nor FTS in the CS, so here we can just return 'Active'
if elementType in ("ComputingElement", "FTS"):
return S_OK({elementName: {"all": "Active"}})
Expand Down Expand Up @@ -270,7 +270,7 @@ def __setCSElementStatus(self, elementName, elementType, statusType, status):
"""
Sets on the CS the Elements status
"""

cs_path = None
# DIRAC doesn't store the status of ComputingElements nor FTS in the CS, so here we can just do nothing
if elementType in ("ComputingElement", "FTS"):
return S_OK()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def parseSwitches():

Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()
query = None
if len(args) < 3:
error("Missing all mandatory 'query', 'element', 'tableType' arguments")
elif args[0].lower() not in ("select", "add", "modify", "delete"):
Expand Down
1 change: 1 addition & 0 deletions src/DIRAC/Resources/Catalog/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def checkCatalogArguments(f):
@functools.wraps(f)
def processWithCheckingArguments(*args, **kwargs):
checkFlag = kwargs.pop("LFNChecking", True)
lfnMap = None
if checkFlag:
argList = list(args)
lfnArgument = argList[1]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" The SGE TimeLeft utility interrogates the SGE batch system for the
current CPU consumed, as well as its limit.
"""

import os
import re
import time
Expand Down Expand Up @@ -43,10 +44,11 @@ def getResourceUsage(self):
lines = str(result["Value"]).split("\n")
for line in lines:
if re.search("usage.*cpu.*", line):
match = re.search(r"cpu=([\d,:]*),", line)
if match:
cpuList = match.groups()[0].split(":")
try:
match = re.search(r"cpu=([\d,:]*),", line)

cpuList = match.groups()[0].split(":")

newcpu = 0.0
if len(cpuList) == 3:
newcpu = float(cpuList[0]) * 3600 + float(cpuList[1]) * 60 + float(cpuList[2])
Expand All @@ -59,8 +61,8 @@ def getResourceUsage(self):
)
if not cpu or newcpu > cpu:
cpu = newcpu
except ValueError:
self.log.warn(f'Problem parsing "{line}" for CPU consumed')
except (ValueError, AttributeError) as e:
self.log.warn(f'Problem parsing "{line}" for CPU consumed {e!r}')
if re.search("hard resource_list.*cpu.*", line):
match = re.search(r"_cpu=(\d*)", line)
if match:
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Resources/Computing/InProcessComputingElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def submitJob(self, executableFile, proxy=None, inputs=None, **kwargs):
"""
payloadEnv = dict(os.environ)
payloadProxy = ""
renewTask = None
if proxy:
self.log.verbose("Setting up proxy for payload")
result = self.writeProxyToFile(proxy)
Expand All @@ -52,7 +53,6 @@ def submitJob(self, executableFile, proxy=None, inputs=None, **kwargs):
renewTask = result["Value"]
else:
self.log.warn("Failed to start proxy renewal task")
renewTask = None

self.submittedJobs += 1
self.runningJobs += 1
Expand Down
Loading

0 comments on commit ae48623

Please sign in to comment.