Skip to content

Commit

Permalink
fix: take into account pylint 3.2.0 recommandation
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed May 15, 2024
1 parent 1663aac commit c9cf7dd
Show file tree
Hide file tree
Showing 45 changed files with 81 additions and 2,230 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 @@ -347,9 +347,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 @@ -201,6 +202,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 stat
Expand Down Expand Up @@ -88,6 +89,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 @@ -621,6 +621,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 @@ def __init__(self, *args, **kw):

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(
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 @@ -671,9 +671,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 @@ -623,6 +623,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
1 change: 1 addition & 0 deletions src/DIRAC/FrameworkSystem/DB/NotificationDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ def __getAlarmIdFromKey(self, alarmKey):
def updateAlarm(self, updateReq):
# Discover alarm identification
idOK = False
alarmModsSQL = None
for field in self.__updateAlarmIdentificationFields:
if field in updateReq:
idOK = True
Expand Down
4 changes: 3 additions & 1 deletion 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 tarfile
import os
import io
Expand Down Expand Up @@ -98,6 +99,7 @@ def export_getListOfBundles(cls):

def transfer_toClient(self, fileId, token, fileHelper):
version = ""
bId = None
if isinstance(fileId, str):
if fileId in ["CAs", "CRLs"]:
return self.__transferFile(fileId, fileHelper)
Expand All @@ -107,7 +109,7 @@ def transfer_toClient(self, fileId, token, fileHelper):
if len(fileId) == 0:
fileHelper.markAsTransferred()
return S_ERROR("No bundle specified!")
elif len(fileId) == 1:
if len(fileId) == 1:
bId = fileId[0]
else:
bId = fileId[0]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" Handler for CAs + CRLs bundles
"""

from base64 import b64encode

from DIRAC import S_OK, S_ERROR
Expand All @@ -13,6 +14,7 @@ class TornadoBundleDeliveryHandler(BundleDeliveryHandlerMixin, TornadoService):

def export_streamToClient(self, fileId):
version = ""
bId = None
if isinstance(fileId, str):
if fileId in ["CAs", "CRLs"]:
retVal = Utilities.generateCAFile() if fileId == "CAs" else Utilities.generateRevokedCertsFile()
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 @@ -70,12 +70,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 @@ -4,6 +4,7 @@
interrogate the DIRAC Accounting.
"""

# FIXME: NOT Usable ATM
# missing doNew, doCache, doMaster

Expand Down Expand Up @@ -56,6 +57,7 @@ def doCommand(self):
period = self.args[4]
grouping = self.args[5]

fromT = toT = None
if period["Format"] == "LastHours":
fromT = datetime.utcnow() - timedelta(hours=period["hours"])
toT = datetime.utcnow()
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
Loading

0 comments on commit c9cf7dd

Please sign in to comment.