updates to allow emane to throw an exception when emane python bindings are not present and emane is attempted to be ran

This commit is contained in:
Blake Harnden 2020-03-31 16:21:04 -07:00
parent 71196004c8
commit 3165bddc92
2 changed files with 11 additions and 3 deletions

View file

@ -33,6 +33,7 @@ from core.emulator.emudata import InterfaceData, LinkOptions, NodeOptions
from core.emulator.enumerations import (
ConfigDataTypes,
EventTypes,
ExceptionLevels,
LinkTypes,
MessageFlags,
NodeTypes,
@ -532,12 +533,12 @@ class CoreHandler(socketserver.BaseRequestHandler):
return
message_handler = self.message_handlers[message.message_type]
try:
# TODO: this needs to be removed, make use of the broadcast message methods
replies = message_handler(message)
self.dispatch_replies(replies, message)
except Exception:
except Exception as e:
self.send_exception(ExceptionLevels.ERROR, "corehandler", str(e))
logging.exception(
"%s: exception while handling message: %s",
threading.currentThread().getName(),
@ -642,7 +643,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
session=self.session.id,
node=node,
date=time.ctime(),
level=level.value,
level=level,
source=source,
text=text,
)

View file

@ -39,6 +39,9 @@ except ImportError:
from emanesh.events import LocationEvent
from emanesh.events.eventserviceexception import EventServiceException
except ImportError:
EventService = None
LocationEvent = None
EventServiceException = None
logging.debug("compatible emane python bindings not installed")
EMANE_MODELS = [
@ -279,6 +282,10 @@ class EmaneManager(ModelManager):
logging.debug("no emane nodes in session")
return EmaneManager.NOT_NEEDED
# check if bindings were installed
if EventService is None:
raise CoreError("EMANE python bindings are not installed")
# control network bridge required for EMANE 0.9.2
# - needs to exist when eventservice binds to it (initeventservice)
otadev = self.get_config("otamanagerdevice")