diff --git a/src/DIRAC/ConfigurationSystem/scripts/dirac_admin_check_config_options.py b/src/DIRAC/ConfigurationSystem/scripts/dirac_admin_check_config_options.py index 82635175fdc..4361da26578 100755 --- a/src/DIRAC/ConfigurationSystem/scripts/dirac_admin_check_config_options.py +++ b/src/DIRAC/ConfigurationSystem/scripts/dirac_admin_check_config_options.py @@ -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) diff --git a/src/DIRAC/Core/Base/AgentModule.py b/src/DIRAC/Core/Base/AgentModule.py index af677eae3fd..b2c3cf0b64c 100644 --- a/src/DIRAC/Core/Base/AgentModule.py +++ b/src/DIRAC/Core/Base/AgentModule.py @@ -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 diff --git a/src/DIRAC/Core/DISET/ServiceReactor.py b/src/DIRAC/Core/DISET/ServiceReactor.py index 6fb7ad19a1e..2f3bd76ced1 100644 --- a/src/DIRAC/Core/DISET/ServiceReactor.py +++ b/src/DIRAC/Core/DISET/ServiceReactor.py @@ -14,6 +14,7 @@ must inherit from the base class RequestHandler """ + import time import datetime import selectors @@ -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: diff --git a/src/DIRAC/Core/Security/VOMS.py b/src/DIRAC/Core/Security/VOMS.py index 31148e37af2..578bd7f1536 100644 --- a/src/DIRAC/Core/Security/VOMS.py +++ b/src/DIRAC/Core/Security/VOMS.py @@ -1,5 +1,6 @@ """ Module for dealing with VOMS (Virtual Organization Membership Service) """ + from datetime import datetime import os import tempfile @@ -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) diff --git a/src/DIRAC/Core/Utilities/ElasticSearchDB.py b/src/DIRAC/Core/Utilities/ElasticSearchDB.py index 53ba7404473..87898cf1e5e 100644 --- a/src/DIRAC/Core/Utilities/ElasticSearchDB.py +++ b/src/DIRAC/Core/Utilities/ElasticSearchDB.py @@ -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") diff --git a/src/DIRAC/Core/Utilities/Graphs/Graph.py b/src/DIRAC/Core/Utilities/Graphs/Graph.py index 7936182eb0b..67e1ccd3769 100644 --- a/src/DIRAC/Core/Utilities/Graphs/Graph.py +++ b/src/DIRAC/Core/Utilities/Graphs/Graph.py @@ -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() @@ -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 diff --git a/src/DIRAC/Core/Utilities/Graphs/GraphUtilities.py b/src/DIRAC/Core/Utilities/Graphs/GraphUtilities.py index d67e63f47ce..2ceaa63e3f6 100644 --- a/src/DIRAC/Core/Utilities/Graphs/GraphUtilities.py +++ b/src/DIRAC/Core/Utilities/Graphs/GraphUtilities.py @@ -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: diff --git a/src/DIRAC/Core/Utilities/Graphs/Legend.py b/src/DIRAC/Core/Utilities/Graphs/Legend.py index 1fe0db592c6..00aa5a8a662 100644 --- a/src/DIRAC/Core/Utilities/Graphs/Legend.py +++ b/src/DIRAC/Core/Utilities/Graphs/Legend.py @@ -3,6 +3,7 @@ The DIRAC Graphs package is derived from the GraphTool plotting package of the CMS/Phedex Project by ... """ + from matplotlib.patches import Rectangle from matplotlib.text import Text from matplotlib.figure import Figure @@ -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 diff --git a/src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py b/src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py index b2fa6fde4cc..db6c34d4971 100644 --- a/src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py +++ b/src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py @@ -3,6 +3,7 @@ The DIRAC Graphs package is derived from the GraphTool plotting package of the CMS/Phedex Project by ... """ + import datetime from pylab import setp from matplotlib.colors import Normalize @@ -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 @@ -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 diff --git a/src/DIRAC/Core/Utilities/Graphs/__init__.py b/src/DIRAC/Core/Utilities/Graphs/__init__.py index 0b721155c08..bef0dd671dd 100644 --- a/src/DIRAC/Core/Utilities/Graphs/__init__.py +++ b/src/DIRAC/Core/Utilities/Graphs/__init__.py @@ -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": diff --git a/src/DIRAC/Core/Utilities/MySQL.py b/src/DIRAC/Core/Utilities/MySQL.py index 46f5428c27c..21efc261771 100755 --- a/src/DIRAC/Core/Utilities/MySQL.py +++ b/src/DIRAC/Core/Utilities/MySQL.py @@ -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): diff --git a/src/DIRAC/DataManagementSystem/Client/DataManager.py b/src/DIRAC/DataManagementSystem/Client/DataManager.py index e604c00d729..f414501e0c0 100644 --- a/src/DIRAC/DataManagementSystem/Client/DataManager.py +++ b/src/DIRAC/DataManagementSystem/Client/DataManager.py @@ -8,6 +8,7 @@ This module consists of DataManager and related classes. """ + # # imports from datetime import datetime, timedelta import fnmatch @@ -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." @@ -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." diff --git a/src/DIRAC/DataManagementSystem/Client/DirectoryListing.py b/src/DIRAC/DataManagementSystem/Client/DirectoryListing.py index 61f5d09d2de..b61dc802f68 100644 --- a/src/DIRAC/DataManagementSystem/Client/DirectoryListing.py +++ b/src/DIRAC/DataManagementSystem/Client/DirectoryListing.py @@ -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: diff --git a/src/DIRAC/DataManagementSystem/Client/FileCatalogClientCLI.py b/src/DIRAC/DataManagementSystem/Client/FileCatalogClientCLI.py index c21342771ae..a8619e16c18 100644 --- a/src/DIRAC/DataManagementSystem/Client/FileCatalogClientCLI.py +++ b/src/DIRAC/DataManagementSystem/Client/FileCatalogClientCLI.py @@ -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(" "): diff --git a/src/DIRAC/DataManagementSystem/Service/StorageElementHandler.py b/src/DIRAC/DataManagementSystem/Service/StorageElementHandler.py index cdfba8a635a..d27d89d41af 100755 --- a/src/DIRAC/DataManagementSystem/Service/StorageElementHandler.py +++ b/src/DIRAC/DataManagementSystem/Service/StorageElementHandler.py @@ -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: diff --git a/src/DIRAC/FrameworkSystem/Client/SystemAdministratorClientCLI.py b/src/DIRAC/FrameworkSystem/Client/SystemAdministratorClientCLI.py index 76c5cda5e51..82a62070c19 100644 --- a/src/DIRAC/FrameworkSystem/Client/SystemAdministratorClientCLI.py +++ b/src/DIRAC/FrameworkSystem/Client/SystemAdministratorClientCLI.py @@ -624,6 +624,7 @@ def do_install(self, args): install executor [-m ] [-p