Skip to content

Commit

Permalink
feat: printing a warning message if not a single CFG file is found
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Mar 30, 2023
1 parent abfedd7 commit bb280c6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/DIRAC/ConfigurationSystem/Client/LocalConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,33 +450,45 @@ def __loadCFGFiles(self):
4. cfg files that come from the command line
"""
errorsList = []
foundCFGFile = False

# 1. $DIRACSYSCONFIG
if "DIRACSYSCONFIG" in os.environ:
diracSysConfigFiles = os.environ["DIRACSYSCONFIG"].replace(" ", "").split(",")
for diracSysConfigFile in reversed(diracSysConfigFiles):
gLogger.debug(f"Loading file from DIRACSYSCONFIG {diracSysConfigFile}")
if os.path.isfile(diracSysConfigFile):
foundCFGFile = True
gConfigurationData.loadFile(diracSysConfigFile)

# 2. ~/.dirac.cfg
if os.path.isfile(os.path.expanduser("~/.dirac.cfg")):
foundCFGFile = True
gConfigurationData.loadFile(os.path.expanduser("~/.dirac.cfg"))

# 3. cfg files specified in addCFGFile calls
for fileName in self.additionalCFGFiles:
gLogger.debug(f"Loading file {fileName}")
if os.path.isfile(fileName):
foundCFGFile = True
gLogger.debug(f"Loading file {fileName}")
retVal = gConfigurationData.loadFile(fileName)
if not retVal["OK"]:
gLogger.debug(f"Could not load file {fileName}: {retVal['Message']}")
errorsList.append(retVal["Message"])

# 4. cfg files that come from the command line
for fileName in self.cliAdditionalCFGFiles:
gLogger.debug(f"Loading file {fileName}")
if os.path.isfile(fileName):
foundCFGFile = True
gLogger.debug(f"Loading file {fileName}")
retVal = gConfigurationData.loadFile(fileName)
if not retVal["OK"]:
gLogger.debug(f"Could not load file {fileName}: {retVal['Message']}")
errorsList.append(retVal["Message"])

if not foundCFGFile:
gLogger.warn("No CFG file loaded, was that intentional?")

return errorsList

def __addUserDataToConfiguration(self):
Expand Down

0 comments on commit bb280c6

Please sign in to comment.