changes to support better type checking for retrieving an arbitrary node from a session, get_node now requires an expected class that the node would be an instance of, if the returned node is not an instance a CoreError is thrown, this also helps editors pick up expected types to account for variable/function usage better as well

This commit is contained in:
Blake Harnden 2020-05-20 14:44:34 -07:00
parent 19ee367dc5
commit d5254e6a91
21 changed files with 149 additions and 126 deletions

View file

@ -21,7 +21,7 @@ from core.emane.rfpipe import EmaneRfPipeModel
from core.emane.tdma import EmaneTdmaModel
from core.emulator.enumerations import ConfigDataTypes, RegisterTlvs
from core.errors import CoreCommandError, CoreError
from core.nodes.base import CoreNode
from core.nodes.base import CoreNode, NodeBase
from core.nodes.interface import CoreInterface
from core.nodes.network import CtrlNet
from core.xml import emanexml
@ -801,8 +801,8 @@ class EmaneManager(ModelManager):
zbit_check = z.bit_length() > 16 or z < 0
if any([xbit_check, ybit_check, zbit_check]):
logging.error(
"Unable to build node location message, received lat/long/alt exceeds coordinate "
"space: NEM %s (%d, %d, %d)",
"Unable to build node location message, received lat/long/alt "
"exceeds coordinate space: NEM %s (%d, %d, %d)",
nemid,
x,
y,
@ -812,7 +812,7 @@ class EmaneManager(ModelManager):
# generate a node message for this location update
try:
node = self.session.get_node(n)
node = self.session.get_node(n, NodeBase)
except CoreError:
logging.exception(
"location event NEM %s has no corresponding node %s", nemid, n