mirror of https://github.com/fail2ban/fail2ban
RF: is_alive -> isAlive to stay consistent in camelCasing
parent
59bf5013c0
commit
78eb4d95eb
|
@ -229,7 +229,7 @@ class Jail:
|
||||||
self.actions.join()
|
self.actions.join()
|
||||||
logSys.info("Jail '%s' stopped" % self.name)
|
logSys.info("Jail '%s' stopped" % self.name)
|
||||||
|
|
||||||
def is_alive(self):
|
def isAlive(self):
|
||||||
"""Check jail "is_alive" by checking filter and actions threads.
|
"""Check jail "isAlive" by checking filter and actions threads.
|
||||||
"""
|
"""
|
||||||
return self.filter.is_alive() or self.actions.is_alive()
|
return self.filter.isAlive() or self.actions.isAlive()
|
||||||
|
|
|
@ -157,7 +157,7 @@ class Server:
|
||||||
def startJail(self, name):
|
def startJail(self, name):
|
||||||
try:
|
try:
|
||||||
self.__lock.acquire()
|
self.__lock.acquire()
|
||||||
if not self.__jails[name].is_alive():
|
if not self.__jails[name].isAlive():
|
||||||
self.__jails[name].start()
|
self.__jails[name].start()
|
||||||
finally:
|
finally:
|
||||||
self.__lock.release()
|
self.__lock.release()
|
||||||
|
@ -166,7 +166,7 @@ class Server:
|
||||||
logSys.debug("Stopping jail %s" % name)
|
logSys.debug("Stopping jail %s" % name)
|
||||||
try:
|
try:
|
||||||
self.__lock.acquire()
|
self.__lock.acquire()
|
||||||
if self.__jails[name].is_alive():
|
if self.__jails[name].isAlive():
|
||||||
self.__jails[name].stop()
|
self.__jails[name].stop()
|
||||||
self.delJail(name)
|
self.delJail(name)
|
||||||
finally:
|
finally:
|
||||||
|
@ -323,12 +323,12 @@ class Server:
|
||||||
def getBanTime(self, name):
|
def getBanTime(self, name):
|
||||||
return self.__jails[name].actions.getBanTime()
|
return self.__jails[name].actions.getBanTime()
|
||||||
|
|
||||||
def is_alive(self, jailnum=None):
|
def isAlive(self, jailnum=None):
|
||||||
if jailnum is not None and len(self.__jails) != jailnum:
|
if jailnum is not None and len(self.__jails) != jailnum:
|
||||||
return 0
|
return 0
|
||||||
for j in self.__jails:
|
for j in self.__jails:
|
||||||
j = self.__jails[j]
|
j = self.__jails[j]
|
||||||
if not j.is_alive():
|
if not j.isAlive():
|
||||||
return 0
|
return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
|
@ -85,5 +85,5 @@ class DummyJail(Jail, object):
|
||||||
def actions(self):
|
def actions(self):
|
||||||
return self.__actions;
|
return self.__actions;
|
||||||
|
|
||||||
def is_alive(self):
|
def isAlive(self):
|
||||||
return True;
|
return True;
|
||||||
|
|
|
@ -594,7 +594,7 @@ def get_monitor_failures_testcase(Filter_):
|
||||||
# actions might be happening too fast in the tests,
|
# actions might be happening too fast in the tests,
|
||||||
# sleep a bit to guarantee reliable time stamps
|
# sleep a bit to guarantee reliable time stamps
|
||||||
if isinstance(self.filter, FilterPoll):
|
if isinstance(self.filter, FilterPoll):
|
||||||
Utils.wait_for(lambda: self.filter.is_alive(), 4*Utils.DEFAULT_SLEEP_TIME)
|
Utils.wait_for(lambda: self.filter.isAlive(), 4*Utils.DEFAULT_SLEEP_TIME)
|
||||||
|
|
||||||
def isEmpty(self, delay=4*Utils.DEFAULT_SLEEP_TIME):
|
def isEmpty(self, delay=4*Utils.DEFAULT_SLEEP_TIME):
|
||||||
# shorter wait time for not modified status
|
# shorter wait time for not modified status
|
||||||
|
|
|
@ -236,7 +236,7 @@ class Transmitter(TransmitterBase):
|
||||||
time.sleep(Utils.DEFAULT_SLEEP_TIME)
|
time.sleep(Utils.DEFAULT_SLEEP_TIME)
|
||||||
# wait until not started (3 seconds as long as any RuntimeError, ex.: RuntimeError('cannot join thread before it is started',)):
|
# wait until not started (3 seconds as long as any RuntimeError, ex.: RuntimeError('cannot join thread before it is started',)):
|
||||||
self.assertTrue( Utils.wait_for(
|
self.assertTrue( Utils.wait_for(
|
||||||
lambda: self.server.is_alive(1) and not isinstance(self.transm.proceed(["status", self.jailName]), RuntimeError),
|
lambda: self.server.isAlive(1) and not isinstance(self.transm.proceed(["status", self.jailName]), RuntimeError),
|
||||||
3) )
|
3) )
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.transm.proceed(["stop", self.jailName]), (0, None))
|
self.transm.proceed(["stop", self.jailName]), (0, None))
|
||||||
|
@ -253,7 +253,7 @@ class Transmitter(TransmitterBase):
|
||||||
# giving it a small delay reliably helps to proceed with tests
|
# giving it a small delay reliably helps to proceed with tests
|
||||||
time.sleep(Utils.DEFAULT_SLEEP_TIME)
|
time.sleep(Utils.DEFAULT_SLEEP_TIME)
|
||||||
self.assertTrue( Utils.wait_for(
|
self.assertTrue( Utils.wait_for(
|
||||||
lambda: self.server.is_alive(2) and not isinstance(self.transm.proceed(["status", self.jailName]), RuntimeError),
|
lambda: self.server.isAlive(2) and not isinstance(self.transm.proceed(["status", self.jailName]), RuntimeError),
|
||||||
3) )
|
3) )
|
||||||
self.assertEqual(self.transm.proceed(["stop", "all"]), (0, None))
|
self.assertEqual(self.transm.proceed(["stop", "all"]), (0, None))
|
||||||
self.assertTrue( Utils.wait_for( lambda: not len(self.server._Server__jails), 3) )
|
self.assertTrue( Utils.wait_for( lambda: not len(self.server._Server__jails), 3) )
|
||||||
|
|
Loading…
Reference in New Issue