added check for config.ini

This commit is contained in:
2021-11-02 09:18:05 -04:00
parent dfbbc07925
commit 691f4e55ca

View File

@@ -72,11 +72,12 @@ configPath = os.path.join(cwd, 'config.ini')
# import the config file
logger.debug("Starting to read the ini config.")
logger.debug("Using file {0}.".format(configPath))
try:
if os.path.exists(configPath):
config = configparser.ConfigParser()
config.read(cwd + '/config.ini')
except ValueError:
logger.critical("Unable to find/read config file. ")
else:
logger.critical("Unable to find/read config file. Please ensure the config.ini is in the same directory as this script and readable.")
exit(1)
serverDNS = config['LDAP SERVER']['server']
serverPort = config['LDAP SERVER'].getint('port')