mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
remove unneded properties
This commit is contained in:
parent
04a8303ca9
commit
1776f91c9e
|
|
@ -30,7 +30,7 @@ class NetCheck:
|
||||||
@param timout: timout for connection check in sec. (1)"""
|
@param timout: timout for connection check in sec. (1)"""
|
||||||
self._hostname = hostname
|
self._hostname = hostname
|
||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
self._connectionState = False
|
self.connectionState = False
|
||||||
self.checkConn() # initiate a first check
|
self.checkConn() # initiate a first check
|
||||||
|
|
||||||
def checkConn(self):
|
def checkConn(self):
|
||||||
|
|
@ -40,14 +40,9 @@ class NetCheck:
|
||||||
try:
|
try:
|
||||||
urlopen(self._hostname, timeout=self._timeout)
|
urlopen(self._hostname, timeout=self._timeout)
|
||||||
logging.debug("%s is reachable", self._hostname)
|
logging.debug("%s is reachable", self._hostname)
|
||||||
self._connectionState = True
|
self.connectionState = True
|
||||||
return True
|
return True
|
||||||
except: # todo find right exception type
|
except: # todo find right exception type
|
||||||
logging.warning("%s is not reachable", self._hostname)
|
logging.warning("%s is not reachable", self._hostname)
|
||||||
self._connectionState = False
|
self.connectionState = False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
|
||||||
def connectionState(self):
|
|
||||||
"""!Property for the last connection state from checkConn()"""
|
|
||||||
return self._connectionState
|
|
||||||
|
|
|
||||||
|
|
@ -25,21 +25,6 @@ class Route:
|
||||||
@param callback: instance of the callback function
|
@param callback: instance of the callback function
|
||||||
@param statsCallback: instance of the callback to get statistics (None)
|
@param statsCallback: instance of the callback to get statistics (None)
|
||||||
"""
|
"""
|
||||||
self._name = name
|
self.name = name
|
||||||
self._callback = callback
|
self.callback = callback
|
||||||
self._statsCallback = statsCallback
|
self.statistics = statsCallback
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""!Property to get the route point name"""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def callback(self):
|
|
||||||
"""!Porperty to get the callback function instance"""
|
|
||||||
return self._callback
|
|
||||||
|
|
||||||
@property
|
|
||||||
def statistics(self):
|
|
||||||
"""!Porperty to get the statistics from instance"""
|
|
||||||
return self._statsCallback
|
|
||||||
|
|
|
||||||
|
|
@ -26,17 +26,17 @@ class Router:
|
||||||
"""!Create a new router
|
"""!Create a new router
|
||||||
|
|
||||||
@param name: name of the router"""
|
@param name: name of the router"""
|
||||||
self._name = name
|
self.name = name
|
||||||
self._routeList = []
|
self.routeList = []
|
||||||
logging.debug("[%s] add new router", self._name)
|
logging.debug("[%s] add new router", self.name)
|
||||||
|
|
||||||
def addRoute(self, route):
|
def addRoute(self, route):
|
||||||
"""!Adds a route point to the router
|
"""!Adds a route point to the router
|
||||||
|
|
||||||
@param route: instance of the Route class
|
@param route: instance of the Route class
|
||||||
"""
|
"""
|
||||||
logging.debug("[%s] add route: %s", self._name, route.name)
|
logging.debug("[%s] add route: %s", self.name, route.name)
|
||||||
self._routeList.append(route)
|
self.routeList.append(route)
|
||||||
|
|
||||||
def runRouter(self, bwPacket):
|
def runRouter(self, bwPacket):
|
||||||
"""!Run the router
|
"""!Run the router
|
||||||
|
|
@ -44,29 +44,19 @@ class Router:
|
||||||
@param bwPacket: instance of Packet class
|
@param bwPacket: instance of Packet class
|
||||||
@return a instance of Packet class
|
@return a instance of Packet class
|
||||||
"""
|
"""
|
||||||
logging.debug("[%s] started", self._name)
|
logging.debug("[%s] started", self.name)
|
||||||
for routeObject in self._routeList:
|
for routeObject in self.routeList:
|
||||||
logging.debug("[%s] -> run route: %s", self._name, routeObject.name)
|
logging.debug("[%s] -> run route: %s", self.name, routeObject.name)
|
||||||
bwPacket_tmp = routeObject.callback(copy.deepcopy(bwPacket)) # copy bwPacket to prevent edit the original
|
bwPacket_tmp = routeObject.callback(copy.deepcopy(bwPacket)) # copy bwPacket to prevent edit the original
|
||||||
|
|
||||||
if bwPacket_tmp is None: # returning None doesnt change the bwPacket
|
if bwPacket_tmp is None: # returning None doesnt change the bwPacket
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if bwPacket_tmp is False: # returning False stops the router immediately
|
if bwPacket_tmp is False: # returning False stops the router immediately
|
||||||
logging.debug("[%s] stopped", self._name)
|
logging.debug("[%s] stopped", self.name)
|
||||||
break
|
break
|
||||||
|
|
||||||
bwPacket = bwPacket_tmp
|
bwPacket = bwPacket_tmp
|
||||||
logging.debug("[%s] <- bwPacket returned: %s", self._name, bwPacket)
|
logging.debug("[%s] <- bwPacket returned: %s", self.name, bwPacket)
|
||||||
logging.debug("[%s] finished", self._name)
|
logging.debug("[%s] finished", self.name)
|
||||||
return bwPacket
|
return bwPacket
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""!Property to get the name of the router"""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def routeList(self):
|
|
||||||
"""!Property to get a list of all route points of this router"""
|
|
||||||
return self._routeList
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue