BF: Change logging instance logSys `warn` method to `warning`

`warn` is long time depreciated method, which may be dropped in
python3.4 http://bugs.python.org/issue13235
pull/183/head
Steven Hiscocks 12 years ago
parent 7341031a30
commit 12df12f282

@ -102,7 +102,7 @@ class Fail2banClient:
def __sigTERMhandler(self, signum, frame):
# Print a new line because we probably come from wait
print
logSys.warn("Caught signal %d. Exiting" % signum)
logSys.warning("Caught signal %d. Exiting" % signum)
sys.exit(-1)
def __getCmdLineOptions(self, optList):

@ -133,7 +133,7 @@ class Beautifier:
c += 1
msg = msg + "`- [" + str(c) + "]: " + response[len(response)-1]
except Exception:
logSys.warn("Beautifier error. Please report the error")
logSys.warning("Beautifier error. Please report the error")
logSys.error("Beautify " + `response` + " with " + `self.__inputCmd` +
" failed")
msg = msg + `response`

@ -70,7 +70,7 @@ class ConfigReader(SafeConfigParserWithIncludes):
# files must carry .conf suffix as well
config_files += sorted(glob.glob('%s/*.conf' % config_dir))
else:
logSys.warn("%s exists but not a directory or not accessible"
logSys.warning("%s exists but not a directory or not accessible"
% config_dir)
# check if files are accessible, warn if any is not accessible
@ -80,7 +80,7 @@ class ConfigReader(SafeConfigParserWithIncludes):
if os.access(f, os.R_OK):
config_files_accessible.append(f)
else:
logSys.warn("%s exists but not accessible - skipping" % f)
logSys.warning("%s exists but not accessible - skipping" % f)
if len(config_files_accessible):
# at least one config exists and accessible
@ -122,11 +122,11 @@ class ConfigReader(SafeConfigParserWithIncludes):
values[option[1]] = option[2]
except NoOptionError:
if not option[2] == None:
logSys.warn("'%s' not defined in '%s'. Using default one: %r"
logSys.warning("'%s' not defined in '%s'. Using default one: %r"
% (option[1], sec, option[2]))
values[option[1]] = option[2]
except ValueError:
logSys.warn("Wrong value for '" + option[1] + "' in '" + sec +
logSys.warning("Wrong value for '" + option[1] + "' in '" + sec +
"'. Using default one: '" + `option[2]` + "'")
values[option[1]] = option[2]
return values

@ -105,7 +105,7 @@ class JailReader(ConfigReader):
logSys.debug("Caught exception: %s" % (e,))
return False
if not len(self.__actions):
logSys.warn("No actions were defined for %s" % self.__name)
logSys.warning("No actions were defined for %s" % self.__name)
return True
def convert(self):

@ -177,7 +177,7 @@ class Actions(JailThread):
aInfo["time"] = bTicket.getTime()
aInfo["matches"] = "".join(bTicket.getMatches())
if self.__banManager.addBanTicket(bTicket):
logSys.warn("[%s] Ban %s" % (self.jail.getName(), aInfo["ip"]))
logSys.warning("[%s] Ban %s" % (self.jail.getName(), aInfo["ip"]))
for action in self.__actions:
action.execActionBan(aInfo)
return True
@ -217,7 +217,7 @@ class Actions(JailThread):
aInfo["failures"] = ticket.getAttempt()
aInfo["time"] = ticket.getTime()
aInfo["matches"] = "".join(ticket.getMatches())
logSys.warn("[%s] Unban %s" % (self.jail.getName(), aInfo["ip"]))
logSys.warning("[%s] Unban %s" % (self.jail.getName(), aInfo["ip"]))
for action in self.__actions:
action.execActionUnban(aInfo)

@ -135,7 +135,7 @@ class AsyncServer(asyncore.dispatcher):
if os.path.exists(sock):
logSys.error("Fail2ban seems to be already running")
if force:
logSys.warn("Forcing execution of the server")
logSys.warning("Forcing execution of the server")
os.remove(sock)
else:
raise AsyncServerException("Server already running")

@ -632,7 +632,7 @@ class FileContainer:
try:
line = line.decode(self.getEncoding(), 'strict')
except UnicodeDecodeError:
logSys.warn("Error decoding line from '%s' with '%s': %s" %
logSys.warning("Error decoding line from '%s' with '%s': %s" %
(self.getFileName(), self.getEncoding(), `line`))
if sys.version_info >= (3,): # In python3, must be decoded
line = line.decode(self.getEncoding(), 'ignore')
@ -668,11 +668,11 @@ class DNSUtils:
try:
return socket.gethostbyname_ex(dns)[2]
except socket.gaierror:
logSys.warn("Unable to find a corresponding IP address for %s"
logSys.warning("Unable to find a corresponding IP address for %s"
% dns)
return list()
except socket.error, e:
logSys.warn("Socket error raised trying to resolve hostname %s: %s"
logSys.warning("Socket error raised trying to resolve hostname %s: %s"
% (dns, e))
return list()
dnsToIp = staticmethod(dnsToIp)

@ -131,10 +131,10 @@ class FilterPoll(FileFilter):
% (filename, e))
self.__file404Cnt[filename] += 1
if self.__file404Cnt[filename] > 2:
logSys.warn("Too many errors. Setting the jail idle")
logSys.warning("Too many errors. Setting the jail idle")
if self.jail:
self.jail.setIdle(True)
else:
logSys.warn("No jail is assigned to %s" % self)
logSys.warning("No jail is assigned to %s" % self)
self.__file404Cnt[filename] = 0
return False

@ -55,7 +55,7 @@ class Transmitter:
ret = self.__commandHandler(command)
ack = 0, ret
except Exception, e:
logSys.warn("Command %r has failed. Received %r"
logSys.warning("Command %r has failed. Received %r"
% (command, e))
ack = 1, e
return ack

Loading…
Cancel
Save