Skip to content

Commit

Permalink
Merge pull request #7227 from chaen/v8.0_fix_pylint
Browse files Browse the repository at this point in the history
test: update to pylint 3.0.0
  • Loading branch information
chrisburr authored Oct 4, 2023
2 parents 0141194 + b1ff0b9 commit 9033890
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/DIRAC/ConfigurationSystem/Client/Helpers/Path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 20 additions & 9 deletions src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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"]:
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit 9033890

Please sign in to comment.