ENH/RF: remove __readJailConfig in favor of __readConfig + catch/error exceptions while reading the configuration

pull/265/head
Yaroslav Halchenko 2013-06-21 11:09:16 -04:00
parent 2974cac40c
commit b6be8b8243
1 changed files with 12 additions and 13 deletions

View File

@ -229,7 +229,7 @@ class Fail2banClient:
elif len(cmd) == 2 and cmd[0] == "reload": elif len(cmd) == 2 and cmd[0] == "reload":
if self.__ping(): if self.__ping():
jail = cmd[1] jail = cmd[1]
ret = self.__readJailConfig(jail) ret = self.__readConfig(jail)
# Do not continue if configuration is not 100% valid # Do not continue if configuration is not 100% valid
if not ret: if not ret:
return False return False
@ -394,19 +394,18 @@ class Fail2banClient:
return False return False
return self.__processCommand(args) return self.__processCommand(args)
def __readConfig(self): def __readConfig(self, jail=None):
# Read the configuration # Read the configuration
self.__configurator.readAll() # TODO: get away from stew of return codes and exception
ret = self.__configurator.getOptions() # handling -- handle via exceptions
self.__configurator.convertToProtocol() try:
self.__stream = self.__configurator.getConfigStream()
return ret
def __readJailConfig(self, jail):
self.__configurator.readAll() self.__configurator.readAll()
ret = self.__configurator.getOptions(jail) ret = self.__configurator.getOptions(jail)
self.__configurator.convertToProtocol() self.__configurator.convertToProtocol()
self.__stream = self.__configurator.getConfigStream() self.__stream = self.__configurator.getConfigStream()
except Exception, e:
logSys.error("Failed during configuration: %s" % e)
ret = False
return ret return ret
#@staticmethod #@staticmethod