diff --git a/src/DIRAC/ConfigurationSystem/Client/Helpers/Path.py b/src/DIRAC/ConfigurationSystem/Client/Helpers/Path.py index 11fb2b493a4..7cb2d87aea7 100644 --- a/src/DIRAC/ConfigurationSystem/Client/Helpers/Path.py +++ b/src/DIRAC/ConfigurationSystem/Client/Helpers/Path.py @@ -18,7 +18,7 @@ def cfgPath(*args): return os.path.normpath(os.path.join(*(str(k) for k in args))) -def cfgInstallPath(*args): +def cfgInstallPath(*args) -> str: """ Path to Installation/Configuration Options """ diff --git a/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/DirectoryMetadata/DirectoryMetadata.py b/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/DirectoryMetadata/DirectoryMetadata.py index 5c46db18faf..d6a511a31f9 100644 --- a/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/DirectoryMetadata/DirectoryMetadata.py +++ b/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/DirectoryMetadata/DirectoryMetadata.py @@ -350,11 +350,8 @@ def getDirectoryMetaParameters(self, dpath, credDict, inherited=True): return S_OK({}) metaDict = {} for _dID, key, value in result["Value"]: - if key in metaDict: - if isinstance(metaDict[key], list): - metaDict[key].append(value) - else: - metaDict[key] = [metaDict[key]].append(value) + if isinstance(metaDict.get(key), list): + metaDict[key].append(value) else: metaDict[key] = value diff --git a/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileMetadata/FileMetadata.py b/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileMetadata/FileMetadata.py index 5b5a248362e..3738866aba5 100644 --- a/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileMetadata/FileMetadata.py +++ b/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileMetadata/FileMetadata.py @@ -358,11 +358,8 @@ def __getFileMetaParameters(self, fileID, credDict): return S_OK({}) metaDict = {} for fileID, key, value in result["Value"]: - if key in metaDict: - if isinstance(metaDict[key], list): - metaDict[key].append(value) - else: - metaDict[key] = [metaDict[key]].append(value) + if isinstance(metaDict.get(key), list): + metaDict[key].append(value) else: metaDict[key] = value diff --git a/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py b/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py index 6578596c98f..e6933518836 100644 --- a/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py +++ b/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py @@ -65,6 +65,7 @@ import subprocess from diraccfg import CFG from prompt_toolkit import prompt +from typing import cast import DIRAC from DIRAC import rootPath @@ -170,7 +171,7 @@ def __init__(self): gLogger.debug("DIRAC Root Path =", rootPath) self.mysqlMode = "" - self.localCfg = None + self.localCfg: CFG = None self.cfgFile = "" self.setup = "" self.instance = "" @@ -1364,10 +1365,20 @@ def setupSite(self, scriptCfg, cfg=None): # Now get the necessary info from self.localCfg setupSystems = self.localCfg.getOption(cfgInstallPath("Systems"), ["Configuration", "Framework"]) + setupDatabases = self.localCfg.getOption(cfgInstallPath("Databases"), []) - setupServices = [k.split("/") for k in self.localCfg.getOption(cfgInstallPath("Services"), [])] - setupAgents = [k.split("/") for k in self.localCfg.getOption(cfgInstallPath("Agents"), [])] - setupExecutors = [k.split("/") for k in self.localCfg.getOption(cfgInstallPath("Executors"), [])] + setupServices = [ + k.split("/") + for k in self.localCfg.getOption(cfgInstallPath("Services"), []) # pylint: disable=not-an-iterable + ] + setupAgents = [ + k.split("/") + for k in self.localCfg.getOption(cfgInstallPath("Agents"), []) # pylint: disable=not-an-iterable + ] + setupExecutors = [ + k.split("/") + for k in self.localCfg.getOption(cfgInstallPath("Executors"), []) # pylint: disable=not-an-iterable + ] setupWeb = self.localCfg.getOption(cfgInstallPath("WebPortal"), False) setupConfigurationMaster = self.localCfg.getOption(cfgInstallPath("ConfigurationMaster"), False) setupPrivateConfiguration = self.localCfg.getOption(cfgInstallPath("PrivateConfiguration"), False) @@ -1382,7 +1393,7 @@ def setupSite(self, scriptCfg, cfg=None): DIRAC.exit(-1) return S_ERROR(error) serviceSysInstance = serviceTuple[0] - if serviceSysInstance not in setupSystems: + if serviceSysInstance not in setupSystems: # pylint: disable=unsupported-membership-test setupSystems.append(serviceSysInstance) for agentTuple in setupAgents: @@ -1393,7 +1404,7 @@ def setupSite(self, scriptCfg, cfg=None): DIRAC.exit(-1) return S_ERROR(error) agentSysInstance = agentTuple[0] - if agentSysInstance not in setupSystems: + if agentSysInstance not in setupSystems: # pylint: disable=unsupported-membership-test setupSystems.append(agentSysInstance) for executorTuple in setupExecutors: @@ -1404,7 +1415,7 @@ def setupSite(self, scriptCfg, cfg=None): DIRAC.exit(-1) return S_ERROR(error) executorSysInstance = executorTuple[0] - if executorSysInstance not in setupSystems: + if executorSysInstance not in setupSystems: # pylint: disable=unsupported-membership-test setupSystems.append(executorSysInstance) # And to find out the available extensions @@ -1521,7 +1532,7 @@ def setupSite(self, scriptCfg, cfg=None): # info to be propagated, this may cause the later self.setup to fail if setupAddConfiguration: gLogger.notice("Registering System instances") - for system in setupSystems: + for system in setupSystems: # pylint: disable=not-an-iterable self.addSystemInstance(system, self.instance, self.setup, True) for system, service in setupServices: if not self.addDefaultOptionsToCS(None, "service", system, service, extensions, overwrite=True)["OK"]: @@ -1570,7 +1581,7 @@ def setupSite(self, scriptCfg, cfg=None): return result dbDict = result["Value"] - for dbName in setupDatabases: + for dbName in setupDatabases: # pylint: disable=not-an-iterable gLogger.verbose("Setting up database", dbName) if dbName not in installedDatabases: result = self.installDatabase(dbName) diff --git a/src/DIRAC/ResourceStatusSystem/scripts/dirac_rss_query_dtcache.py b/src/DIRAC/ResourceStatusSystem/scripts/dirac_rss_query_dtcache.py index a616153df08..0df80307717 100755 --- a/src/DIRAC/ResourceStatusSystem/scripts/dirac_rss_query_dtcache.py +++ b/src/DIRAC/ResourceStatusSystem/scripts/dirac_rss_query_dtcache.py @@ -43,10 +43,12 @@ def parseSwitches(): args = Script.getPositionalArgs() if not args: error("Missing mandatory 'query' argument") + DIRACExit(1) elif not args[0].lower() in ("select", "add", "delete"): error("Missing mandatory argument") - else: - query = args[0].lower() + DIRACExit(1) + + query = args[0].lower() switches = dict(Script.getUnprocessedSwitches())