mirror of https://github.com/fail2ban/fail2ban
ENH: minor formatting, no functional changes
parent
4a83741397
commit
9339293413
|
@ -47,7 +47,8 @@ if sys.version_info >= (3,):
|
||||||
return x
|
return x
|
||||||
def _json_loads_safe(x):
|
def _json_loads_safe(x):
|
||||||
try:
|
try:
|
||||||
x = json.loads(x.decode(locale.getpreferredencoding(), 'replace'))
|
x = json.loads(x.decode(
|
||||||
|
locale.getpreferredencoding(), 'replace'))
|
||||||
except Exception, e: # pragma: no cover
|
except Exception, e: # pragma: no cover
|
||||||
logSys.error('json loads failed: %s', e)
|
logSys.error('json loads failed: %s', e)
|
||||||
x = {}
|
x = {}
|
||||||
|
@ -72,7 +73,8 @@ else:
|
||||||
return x
|
return x
|
||||||
def _json_loads_safe(x):
|
def _json_loads_safe(x):
|
||||||
try:
|
try:
|
||||||
x = _normalize(json.loads(x.decode(locale.getpreferredencoding(), 'replace')))
|
x = _normalize(json.loads(x.decode(
|
||||||
|
locale.getpreferredencoding(), 'replace')))
|
||||||
except Exception, e: # pragma: no cover
|
except Exception, e: # pragma: no cover
|
||||||
logSys.error('json loads failed: %s', e)
|
logSys.error('json loads failed: %s', e)
|
||||||
x = {}
|
x = {}
|
||||||
|
@ -406,7 +408,7 @@ class Fail2BanDb(object):
|
||||||
"INSERT INTO bans(jail, ip, timeofban, data) VALUES(?, ?, ?, ?)",
|
"INSERT INTO bans(jail, ip, timeofban, data) VALUES(?, ?, ?, ?)",
|
||||||
(jail.name, ticket.getIP(), int(round(ticket.getTime())),
|
(jail.name, ticket.getIP(), int(round(ticket.getTime())),
|
||||||
{"matches": ticket.getMatches(),
|
{"matches": ticket.getMatches(),
|
||||||
"failures": ticket.getAttempt()}))
|
"failures": ticket.getAttempt()}))
|
||||||
|
|
||||||
@commitandrollback
|
@commitandrollback
|
||||||
def delBan(self, cur, jail, ticket):
|
def delBan(self, cur, jail, ticket):
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Ticket:
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
try:
|
try:
|
||||||
return self.__ip == other.__ip and \
|
return self.__ip == other.__ip and \
|
||||||
round(self.__time,2) == round(other.__time,2) and \
|
round(self.__time, 2) == round(other.__time, 2) and \
|
||||||
self.__attempt == other.__attempt and \
|
self.__attempt == other.__attempt and \
|
||||||
self.__matches == other.__matches
|
self.__matches == other.__matches
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
Loading…
Reference in New Issue