Increase discoverability by telling user both the filename and the directories searched if config file is missing
This commit is contained in:
@ -324,6 +324,7 @@ def main():
|
||||
logging.debug('Starting as PID %s', os.getpid())
|
||||
|
||||
found = False
|
||||
config_dirs = ('/etc/routerstats/', '/usr/local/etc/routerstats/', '/opt/routerstats/', './')
|
||||
if args.config:
|
||||
if os.path.isfile(args.config):
|
||||
config.read(args.config)
|
||||
@ -333,14 +334,14 @@ def main():
|
||||
else:
|
||||
logging.debug('Trying to find config')
|
||||
#Try to find in "usual" places
|
||||
for directory in ('/etc/routerstats/', '/usr/local/etc/routerstats/', '/opt/routerstats/', './'):
|
||||
for directory in config_dirs:
|
||||
trytoread = directory + 'routerstats.config'
|
||||
if os.path.isfile(trytoread):
|
||||
logging.debug('Reading config file %s', trytoread)
|
||||
config.read(trytoread)
|
||||
found = True
|
||||
if not found:
|
||||
logging.error('No config file found')
|
||||
logging.error('routerstats.config not found in %s', config_dirs)
|
||||
sys.exit(0)
|
||||
|
||||
parser.add_argument(
|
||||
|
||||
@ -450,6 +450,7 @@ def main():
|
||||
logging.debug('Starting as PID %s' ,os.getpid())
|
||||
|
||||
found = False
|
||||
config_dirs = ('/etc/routerstats/', '/usr/local/etc/routerstats/', '/opt/routerstats/', './')
|
||||
if args.config:
|
||||
if os.path.isfile(args.config):
|
||||
config.read(args.config)
|
||||
@ -459,14 +460,14 @@ def main():
|
||||
else:
|
||||
logging.debug('Trying to find config')
|
||||
#Try to find in "usual" places
|
||||
for directory in ('/etc/routerstats/', '/usr/local/etc/routerstats/', '/opt/routerstats/', './'):
|
||||
for directory in config_dirs:
|
||||
trytoread = directory + 'routerstats.config'
|
||||
if os.path.isfile(trytoread):
|
||||
logging.debug('Reading config file %s', trytoread)
|
||||
config.read(trytoread)
|
||||
found = True
|
||||
if not found:
|
||||
logging.error('No config file found')
|
||||
logging.error('routerstats.config not found in %s', config_dirs)
|
||||
sys.exit(0)
|
||||
|
||||
parser.add_argument(
|
||||
|
||||
@ -136,6 +136,7 @@ def main():
|
||||
logging.debug('Starting as PID %s', os.getpid())
|
||||
|
||||
found = False
|
||||
config_dirs = ('/etc/routerstats/', '/usr/local/etc/routerstats/', '/opt/routerstats/', './')
|
||||
if args.config:
|
||||
if os.path.isfile(args.config):
|
||||
config.read(args.config)
|
||||
@ -145,14 +146,14 @@ def main():
|
||||
else:
|
||||
logging.debug('Trying to find config')
|
||||
#Try to find in "usual" places
|
||||
for directory in ('/etc/routerstats/', '/usr/local/etc/routerstats/', '/opt/routerstats/', './'):
|
||||
for directory in config_dirs:
|
||||
trytoread = directory + 'routerstats.config'
|
||||
if os.path.isfile(trytoread):
|
||||
logging.debug('Reading config file %s', trytoread)
|
||||
config.read(trytoread)
|
||||
found = True
|
||||
if not found:
|
||||
logging.error('No config file found')
|
||||
logging.error('routerstats.config not found in %s', config_dirs)
|
||||
sys.exit(0)
|
||||
|
||||
parser.add_argument(
|
||||
|
||||
Reference in New Issue
Block a user