From 691f4e55ca399fc5abd654ff73d1bfb04b37a32e Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Tue, 2 Nov 2021 09:18:05 -0400 Subject: [PATCH] added check for config.ini --- seafile-ldap.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/seafile-ldap.py b/seafile-ldap.py index 79a192e..f5f714d 100644 --- a/seafile-ldap.py +++ b/seafile-ldap.py @@ -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')