remove unneded properties

This commit is contained in:
Bastian Schroll 2019-10-25 13:43:50 +02:00
parent 04a8303ca9
commit 1776f91c9e
No known key found for this signature in database
GPG key ID: 0AE96912A20E9F5F
3 changed files with 17 additions and 47 deletions

View file

@ -30,7 +30,7 @@ class NetCheck:
@param timout: timout for connection check in sec. (1)"""
self._hostname = hostname
self._timeout = timeout
self._connectionState = False
self.connectionState = False
self.checkConn() # initiate a first check
def checkConn(self):
@ -40,14 +40,9 @@ class NetCheck:
try:
urlopen(self._hostname, timeout=self._timeout)
logging.debug("%s is reachable", self._hostname)
self._connectionState = True
self.connectionState = True
return True
except: # todo find right exception type
logging.warning("%s is not reachable", self._hostname)
self._connectionState = False
self.connectionState = False
return False
@property
def connectionState(self):
"""!Property for the last connection state from checkConn()"""
return self._connectionState

View file

@ -25,21 +25,6 @@ class Route:
@param callback: instance of the callback function
@param statsCallback: instance of the callback to get statistics (None)
"""
self._name = name
self._callback = callback
self._statsCallback = 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
self.name = name
self.callback = callback
self.statistics = statsCallback

View file

@ -26,17 +26,17 @@ class Router:
"""!Create a new router
@param name: name of the router"""
self._name = name
self._routeList = []
logging.debug("[%s] add new router", self._name)
self.name = name
self.routeList = []
logging.debug("[%s] add new router", self.name)
def addRoute(self, route):
"""!Adds a route point to the router
@param route: instance of the Route class
"""
logging.debug("[%s] add route: %s", self._name, route.name)
self._routeList.append(route)
logging.debug("[%s] add route: %s", self.name, route.name)
self.routeList.append(route)
def runRouter(self, bwPacket):
"""!Run the router
@ -44,29 +44,19 @@ class Router:
@param bwPacket: instance of Packet class
@return a instance of Packet class
"""
logging.debug("[%s] started", self._name)
for routeObject in self._routeList:
logging.debug("[%s] -> run route: %s", self._name, routeObject.name)
logging.debug("[%s] started", self.name)
for routeObject in self.routeList:
logging.debug("[%s] -> run route: %s", self.name, routeObject.name)
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
continue
if bwPacket_tmp is False: # returning False stops the router immediately
logging.debug("[%s] stopped", self._name)
logging.debug("[%s] stopped", self.name)
break
bwPacket = bwPacket_tmp
logging.debug("[%s] <- bwPacket returned: %s", self._name, bwPacket)
logging.debug("[%s] finished", self._name)
logging.debug("[%s] <- bwPacket returned: %s", self.name, bwPacket)
logging.debug("[%s] finished", self.name)
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