mirror of https://github.com/fail2ban/fail2ban
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/issue13235pull/183/head
parent
7341031a30
commit
12df12f282
|
@ -102,7 +102,7 @@ class Fail2banClient:
|
||||||
def __sigTERMhandler(self, signum, frame):
|
def __sigTERMhandler(self, signum, frame):
|
||||||
# Print a new line because we probably come from wait
|
# Print a new line because we probably come from wait
|
||||||
print
|
print
|
||||||
logSys.warn("Caught signal %d. Exiting" % signum)
|
logSys.warning("Caught signal %d. Exiting" % signum)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
def __getCmdLineOptions(self, optList):
|
def __getCmdLineOptions(self, optList):
|
||||||
|
|
|
@ -133,7 +133,7 @@ class Beautifier:
|
||||||
c += 1
|
c += 1
|
||||||
msg = msg + "`- [" + str(c) + "]: " + response[len(response)-1]
|
msg = msg + "`- [" + str(c) + "]: " + response[len(response)-1]
|
||||||
except Exception:
|
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` +
|
logSys.error("Beautify " + `response` + " with " + `self.__inputCmd` +
|
||||||
" failed")
|
" failed")
|
||||||
msg = msg + `response`
|
msg = msg + `response`
|
||||||
|
|
|
@ -70,7 +70,7 @@ class ConfigReader(SafeConfigParserWithIncludes):
|
||||||
# files must carry .conf suffix as well
|
# files must carry .conf suffix as well
|
||||||
config_files += sorted(glob.glob('%s/*.conf' % config_dir))
|
config_files += sorted(glob.glob('%s/*.conf' % config_dir))
|
||||||
else:
|
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)
|
% config_dir)
|
||||||
|
|
||||||
# check if files are accessible, warn if any is not accessible
|
# 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):
|
if os.access(f, os.R_OK):
|
||||||
config_files_accessible.append(f)
|
config_files_accessible.append(f)
|
||||||
else:
|
else:
|
||||||
logSys.warn("%s exists but not accessible - skipping" % f)
|
logSys.warning("%s exists but not accessible - skipping" % f)
|
||||||
|
|
||||||
if len(config_files_accessible):
|
if len(config_files_accessible):
|
||||||
# at least one config exists and accessible
|
# at least one config exists and accessible
|
||||||
|
@ -122,11 +122,11 @@ class ConfigReader(SafeConfigParserWithIncludes):
|
||||||
values[option[1]] = option[2]
|
values[option[1]] = option[2]
|
||||||
except NoOptionError:
|
except NoOptionError:
|
||||||
if not option[2] == None:
|
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]))
|
% (option[1], sec, option[2]))
|
||||||
values[option[1]] = option[2]
|
values[option[1]] = option[2]
|
||||||
except ValueError:
|
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]` + "'")
|
"'. Using default one: '" + `option[2]` + "'")
|
||||||
values[option[1]] = option[2]
|
values[option[1]] = option[2]
|
||||||
return values
|
return values
|
||||||
|
|
|
@ -105,7 +105,7 @@ class JailReader(ConfigReader):
|
||||||
logSys.debug("Caught exception: %s" % (e,))
|
logSys.debug("Caught exception: %s" % (e,))
|
||||||
return False
|
return False
|
||||||
if not len(self.__actions):
|
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
|
return True
|
||||||
|
|
||||||
def convert(self):
|
def convert(self):
|
||||||
|
|
|
@ -177,7 +177,7 @@ class Actions(JailThread):
|
||||||
aInfo["time"] = bTicket.getTime()
|
aInfo["time"] = bTicket.getTime()
|
||||||
aInfo["matches"] = "".join(bTicket.getMatches())
|
aInfo["matches"] = "".join(bTicket.getMatches())
|
||||||
if self.__banManager.addBanTicket(bTicket):
|
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:
|
for action in self.__actions:
|
||||||
action.execActionBan(aInfo)
|
action.execActionBan(aInfo)
|
||||||
return True
|
return True
|
||||||
|
@ -217,7 +217,7 @@ class Actions(JailThread):
|
||||||
aInfo["failures"] = ticket.getAttempt()
|
aInfo["failures"] = ticket.getAttempt()
|
||||||
aInfo["time"] = ticket.getTime()
|
aInfo["time"] = ticket.getTime()
|
||||||
aInfo["matches"] = "".join(ticket.getMatches())
|
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:
|
for action in self.__actions:
|
||||||
action.execActionUnban(aInfo)
|
action.execActionUnban(aInfo)
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ class AsyncServer(asyncore.dispatcher):
|
||||||
if os.path.exists(sock):
|
if os.path.exists(sock):
|
||||||
logSys.error("Fail2ban seems to be already running")
|
logSys.error("Fail2ban seems to be already running")
|
||||||
if force:
|
if force:
|
||||||
logSys.warn("Forcing execution of the server")
|
logSys.warning("Forcing execution of the server")
|
||||||
os.remove(sock)
|
os.remove(sock)
|
||||||
else:
|
else:
|
||||||
raise AsyncServerException("Server already running")
|
raise AsyncServerException("Server already running")
|
||||||
|
|
|
@ -632,7 +632,7 @@ class FileContainer:
|
||||||
try:
|
try:
|
||||||
line = line.decode(self.getEncoding(), 'strict')
|
line = line.decode(self.getEncoding(), 'strict')
|
||||||
except UnicodeDecodeError:
|
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`))
|
(self.getFileName(), self.getEncoding(), `line`))
|
||||||
if sys.version_info >= (3,): # In python3, must be decoded
|
if sys.version_info >= (3,): # In python3, must be decoded
|
||||||
line = line.decode(self.getEncoding(), 'ignore')
|
line = line.decode(self.getEncoding(), 'ignore')
|
||||||
|
@ -668,11 +668,11 @@ class DNSUtils:
|
||||||
try:
|
try:
|
||||||
return socket.gethostbyname_ex(dns)[2]
|
return socket.gethostbyname_ex(dns)[2]
|
||||||
except socket.gaierror:
|
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)
|
% dns)
|
||||||
return list()
|
return list()
|
||||||
except socket.error, e:
|
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))
|
% (dns, e))
|
||||||
return list()
|
return list()
|
||||||
dnsToIp = staticmethod(dnsToIp)
|
dnsToIp = staticmethod(dnsToIp)
|
||||||
|
|
|
@ -131,10 +131,10 @@ class FilterPoll(FileFilter):
|
||||||
% (filename, e))
|
% (filename, e))
|
||||||
self.__file404Cnt[filename] += 1
|
self.__file404Cnt[filename] += 1
|
||||||
if self.__file404Cnt[filename] > 2:
|
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:
|
if self.jail:
|
||||||
self.jail.setIdle(True)
|
self.jail.setIdle(True)
|
||||||
else:
|
else:
|
||||||
logSys.warn("No jail is assigned to %s" % self)
|
logSys.warning("No jail is assigned to %s" % self)
|
||||||
self.__file404Cnt[filename] = 0
|
self.__file404Cnt[filename] = 0
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Transmitter:
|
||||||
ret = self.__commandHandler(command)
|
ret = self.__commandHandler(command)
|
||||||
ack = 0, ret
|
ack = 0, ret
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logSys.warn("Command %r has failed. Received %r"
|
logSys.warning("Command %r has failed. Received %r"
|
||||||
% (command, e))
|
% (command, e))
|
||||||
ack = 1, e
|
ack = 1, e
|
||||||
return ack
|
return ack
|
||||||
|
|
Loading…
Reference in New Issue