@commitandrollback decorator added; missing logging module reference added;

pull/716/head
sebres 2014-07-07 10:28:46 +02:00
parent 00b7205a3c
commit e70406d5a1
2 changed files with 5 additions and 5 deletions

View File

@ -512,7 +512,8 @@ class Fail2BanDb(object):
self._bansMergedCache[cacheKey] = tickets if ip is None else ticket self._bansMergedCache[cacheKey] = tickets if ip is None else ticket
return tickets if ip is None else ticket return tickets if ip is None else ticket
def getBan(self, ip, jail=None, forbantime=None, overalljails=None, fromtime=None): @commitandrollback
def getBan(self, cur, ip, jail=None, forbantime=None, overalljails=None, fromtime=None):
if not overalljails: if not overalljails:
query = "SELECT bancount, timeofban, bantime FROM bips" query = "SELECT bancount, timeofban, bantime FROM bips"
else: else:
@ -531,10 +532,10 @@ class Fail2BanDb(object):
if overalljails or jail is None: if overalljails or jail is None:
query += " GROUP BY ip ORDER BY timeofban DESC LIMIT 1" query += " GROUP BY ip ORDER BY timeofban DESC LIMIT 1"
cur = self._db.cursor() cur = self._db.cursor()
#logSys.debug((query, queryArgs));
return cur.execute(query, queryArgs) return cur.execute(query, queryArgs)
def _getCurrentBans(self, jail = None, ip = None, forbantime=None, fromtime=None): @commitandrollback
def _getCurrentBans(self, cur, jail = None, ip = None, forbantime=None, fromtime=None):
if fromtime is None: if fromtime is None:
fromtime = MyTime.time() fromtime = MyTime.time()
queryArgs = [] queryArgs = []
@ -554,7 +555,6 @@ class Fail2BanDb(object):
if ip is None: if ip is None:
query += " GROUP BY ip ORDER BY ip, timeofban DESC" query += " GROUP BY ip ORDER BY ip, timeofban DESC"
cur = self._db.cursor() cur = self._db.cursor()
#logSys.debug((query, queryArgs));
return cur.execute(query, queryArgs) return cur.execute(query, queryArgs)
def getCurrentBans(self, jail = None, ip = None, forbantime=None, fromtime=None): def getCurrentBans(self, jail = None, ip = None, forbantime=None, fromtime=None):

View File

@ -26,7 +26,7 @@ __copyright__ = "Copyright (c) 2014 Serg G. Brester"
__license__ = "GPL" __license__ = "GPL"
import threading import threading
import os, time, datetime, math, json, random import os, logging, time, datetime, math, json, random
import sys import sys
from ..helpers import getLogger from ..helpers import getLogger
from .mytime import MyTime from .mytime import MyTime