Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
MANTA-962 Add a user error for missing ini file
Browse files Browse the repository at this point in the history
The configuration ini file is required, but there previously was no
check for the default ini file, which could be missing if an
installation problem occurs. This adds a simple check for the defualt
ini file, and improves the error message for missing default or custom
ini files.

Closes #79
  • Loading branch information
ctsa committed May 8, 2017
1 parent f7fe4b7 commit a88f367
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/python/lib/configureOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,29 @@ def updateIniSections(data,newData) :
version=version, configHelp=configHelp)
(options,args) = parser.parse_args()

if options.userConfigPath :
if not os.path.isfile(options.userConfigPath) :
raise OptParseException("Can't find config file: '%s'" % (options.userConfigPath))
try:
if options.userConfigPath :
if not os.path.isfile(options.userConfigPath) :
raise OptParseException("Can't find config file: '%s'" % (options.userConfigPath))

updateIniSections(iniSections,getIniSections(options.userConfigPath))
updateIniSections(iniSections,getIniSections(options.userConfigPath))

# reparse with updated default values:
parser=self._getOptionParser(iniSections[primary_section],configFileName, cmdlineScriptDir,
version=version, configHelp=configHelp)
(options,args) = parser.parse_args()
# reparse with updated default values:
parser=self._getOptionParser(iniSections[primary_section],configFileName, cmdlineScriptDir,
version=version, configHelp=configHelp)
(options,args) = parser.parse_args()
else :
if not os.path.isfile(globalConfigPath) :
raise OptParseException("Can't find default config file: '%s'" % (globalConfigPath))

if options.isAllHelp :
# this second call to getOptionParser is only here to provide the extended help option:
parser=self._getOptionParser(iniSections[primary_section],configFileName, cmdlineScriptDir, True,
version=version, configHelp=configHelp)
parser.print_help()
sys.exit(2)

try :
if options.isAllHelp :
# this second call to getOptionParser is only here to provide the extended help option:
parser=self._getOptionParser(iniSections[primary_section],configFileName, cmdlineScriptDir, True,
version=version, configHelp=configHelp)
parser.print_help()
sys.exit(2)

nargs=len(args)
if nargs :
plural=""
Expand Down

0 comments on commit a88f367

Please sign in to comment.