'Check for IP address to ban.
Look in the jail queue for FailTicket. If a ticket is available,
it executes the "ban" command and adds a ticket to the BanManager.
Returns
bool
True if an IP address get banned.'

def __checkBan(self):

    cnt = 0
    while (cnt < 100):
        ticket = self._jail.getFailTicket()
        if (not ticket):
            break
        bTicket = BanTicket.wrap(ticket)
        btime = ticket.getBanTime(self.__banManager.getBanTime())
        ip = bTicket.getIP()
        aInfo = self.__getActionInfo(bTicket)
        reason = {}
        if self.__banManager.addBanTicket(bTicket, reason=reason):
            cnt += 1
            if ((Observers.Main is not None) and (not bTicket.restored)):
                Observers.Main.add('banFound', bTicket, self._jail, btime)
            logSys.notice('[%s]    %sBan    %s', self._jail.name, ('' if (not bTicket.restored) else 'Restore    '), ip)
            for (name, action) in self._actions.iteritems():
                try:
                    if (ticket.restored and getattr(action, 'norestored', False)):
                        continue
                    if (not aInfo.immutable):
                        aInfo.reset()
                    action.ban(aInfo)
                except Exception as e:
                    logSys.error("Failed    to    execute    ban    jail    '%s'    action    '%s'    info    '%r':    %s", self._jail.name, name, aInfo, e, exc_info=(logSys.getEffectiveLevel() <= logging.DEBUG))
            bTicket.banned = True
        else:
            if reason.get('expired', 0):
                logSys.info('[%s]    Ignore    %s,    expired    bantime', self._jail.name, ip)
                continue
            bTicket = reason.get('ticket', bTicket)
            if bTicket.banned:
                diftm = (ticket.getTime() - bTicket.getTime())
                ll = (logging.DEBUG if (diftm < 3) else (logging.NOTICE if (diftm < 60) else logging.WARNING))
                logSys.log(ll, '[%s]    %s    already    banned', self._jail.name, ip)
    if cnt:
        logSys.debug('Banned    %s    /    %s,    %s    ticket(s)    in    %r', cnt, self.__banManager.getBanTotal(), self.__banManager.size(), self._jail.name)
    return cnt
