Skip to content

Commit bb280c6

Browse files
committed
feat: printing a warning message if not a single CFG file is found
1 parent abfedd7 commit bb280c6

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/DIRAC/ConfigurationSystem/Client/LocalConfiguration.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,33 +450,45 @@ def __loadCFGFiles(self):
450450
4. cfg files that come from the command line
451451
"""
452452
errorsList = []
453+
foundCFGFile = False
453454

454455
# 1. $DIRACSYSCONFIG
455456
if "DIRACSYSCONFIG" in os.environ:
456457
diracSysConfigFiles = os.environ["DIRACSYSCONFIG"].replace(" ", "").split(",")
457458
for diracSysConfigFile in reversed(diracSysConfigFiles):
458459
gLogger.debug(f"Loading file from DIRACSYSCONFIG {diracSysConfigFile}")
460+
if os.path.isfile(diracSysConfigFile):
461+
foundCFGFile = True
459462
gConfigurationData.loadFile(diracSysConfigFile)
460463

461464
# 2. ~/.dirac.cfg
465+
if os.path.isfile(os.path.expanduser("~/.dirac.cfg")):
466+
foundCFGFile = True
462467
gConfigurationData.loadFile(os.path.expanduser("~/.dirac.cfg"))
463468

464469
# 3. cfg files specified in addCFGFile calls
465470
for fileName in self.additionalCFGFiles:
466-
gLogger.debug(f"Loading file {fileName}")
471+
if os.path.isfile(fileName):
472+
foundCFGFile = True
473+
gLogger.debug(f"Loading file {fileName}")
467474
retVal = gConfigurationData.loadFile(fileName)
468475
if not retVal["OK"]:
469476
gLogger.debug(f"Could not load file {fileName}: {retVal['Message']}")
470477
errorsList.append(retVal["Message"])
471478

472479
# 4. cfg files that come from the command line
473480
for fileName in self.cliAdditionalCFGFiles:
474-
gLogger.debug(f"Loading file {fileName}")
481+
if os.path.isfile(fileName):
482+
foundCFGFile = True
483+
gLogger.debug(f"Loading file {fileName}")
475484
retVal = gConfigurationData.loadFile(fileName)
476485
if not retVal["OK"]:
477486
gLogger.debug(f"Could not load file {fileName}: {retVal['Message']}")
478487
errorsList.append(retVal["Message"])
479488

489+
if not foundCFGFile:
490+
gLogger.warn("No CFG file loaded, was that intentional?")
491+
480492
return errorsList
481493

482494
def __addUserDataToConfiguration(self):

0 commit comments

Comments
 (0)