Exemplo n.º 1
0
 def handleListUtterancesMsg(self, msg):
     scriptData = msg.getActor()
     segment = msg.getContextValue(SEGMENT_CONTEXT_TAG, False)
     msTag = msg.getContextValue(MS_XML_CONTEXT_TAG, False)
     msTypeTag = msg.getContextValue(MS_XML_TYPE_CONTEXT_TAG, None)
     transformDialog = msg.getContextValue(
         TRANSFORM_DIALOG_PACK_CONTEXT_TAG, False)
     agentName = msg.getContextValue(AGENT_CONTEXT_TAG, None)
     try:
         if isinstance(scriptData, (ASATDialogPack, ASATTutoringScript)):
             utterances = self.getUtterancesFromPack(
                 scriptData, segment, transformDialog, agentName)
             utterances = self.cleanUtterances(utterances)
             if msTag:
                 utterances = makeMediaSemanticsMsgXMLList(
                     utterances, msTypeTag)
             msg = self.makeDuplicateMsg(msg, INFORM_ACT)
             msg.setResult(utterances)
             self.sendMessage(msg)
         elif isinstance(scriptData, TutoringPageView):
             self.getUtterancesFromTutoringPage(msg, scriptData, segment,
                                                msTag, msTypeTag,
                                                transformDialog, agentName)
         else:
             msg = self.makeDuplicateMsg(msg, DISCONFIRM_ACT)
             msg.setResult(None)
             self.sendMessage(msg)
     except ValueError, err:
         #except ValueException, err:
         logError(err)
         utterances = None
         msg = self.makeDuplicateMsg(msg, DISCONFIRM_ACT)
         msg.setResult(None)
         self.sendMessage(msg)
Exemplo n.º 2
0
def receive_message(message):
    try:
        MESSAGING_GATEWAY.onReceiveAJAXMessage(message, flask.request.sid)     
    except Exception as err:
        if DEBUG_MODE:
            raise
        else:
            logError(err, stack=traceback.format_exc())
Exemplo n.º 3
0
 def receive_message(message):
     try:
         MESSAGING_GATEWAY.onReceiveAJAXMessage(message)
     except Exception, err:
         if DEBUG_MODE:
             raise
         else:
             logError(err, stack=traceback.format_exc())
Exemplo n.º 4
0
def background_thread():
    try:
        MESSAGING_GATEWAY.processQueuedMessages()
    except Exception as err:
        #if DEBUG_MODE:
        #    raise
        #else:
        logError(err, stack=traceback.format_exc())
        MESSAGING_GATEWAY.processQueuedMessages()
def background_thread():
    try:
        MESSAGING_GATEWAY.processQueuedMessages()
    except Exception as err:
        #if DEBUG_MODE:
        #    raise
        #else:
        logError(err, stack=traceback.format_exc())
        MESSAGING_GATEWAY.processQueuedMessages()
Exemplo n.º 6
0
 def background_thread():
     #@TODO: TEST AND MAKE SURE THIS workS WITH GUNICORN (if we use that)
     try:
         MESSAGING_GATEWAY.processQueuedMessages()
     except Exception, err:
         if DEBUG_MODE:
             raise
         else:
             logError(err, stack=traceback.format_exc())
             MESSAGING_GATEWAY.processQueuedMessages()
Exemplo n.º 7
0
 def queueAJAXMessage(self, msg):
     #logWarning("QUEUE MSG", msg.saveToSerialized())
     try:
         sessionId = msg.getContextValue(SESSION_KEY, None)
         sid = msg.getContextValue("sid", None)
         msg = serializeObject(msg)
         self._messages.put((sid, sessionId, msg))
         print("AJAX message queued")
     except Exception as err:
         print("AJAX message failed to queue")
         logError(err, stack=traceback.format_exc())
Exemplo n.º 8
0
def StartServer(app=None, socketio=None, host=None, port=DEFAULT_PORT, debug=True):
    if socketio is None: socketio = SOCKET_IO_CORE
    if host is None:
        if debug:
            host = '0.0.0.0'
        else:
            host = '127.0.0.1'
    Thread(target=background_thread).start()
    logWarning("Starting Socket App1")
    try:
        logWarning(host)
        logWarning(port)
        socketio.run(app, host=host, port=port)
    except Exception as err:
        logError("Error: Could not start socketio.")
        DB_CONNECTION.close()
def StartServer(app=None, socketio=None, host=None, port=DEFAULT_PORT, debug=True):
    if socketio is None: socketio = SOCKET_IO_CORE
    if host is None:
        if debug:
            host = '0.0.0.0'
        else:
            host = '127.0.0.1'
    Thread(target=background_thread).start()
    logWarning("Starting Socket App1")
    try:
        logWarning(host)
        logWarning(port)
        socketio.run(app, host=host, port=port)
    except Exception as err:
        logError("Error: Could not start socketio.")
        DB_CONNECTION.close()
Exemplo n.º 10
0
    def on_message(self, headers, msg):
        msg = urllib.parse.unquote(msg)
        msg = msg.replace("+", " ")

        #Only handle superglu messages like this.  for the moment we will ignore other message types until the ontology broker is ready
        if self.MESSAGE_SYSTEM_NAME in headers:
            if headers[self.MESSAGE_SYSTEM_NAME] == self.SUPERGLU:

                try:
                    msg = nativizeObject(msg)
                    if isinstance(msg, Message):
                        if self._gateway is not None:
                            self._gateway.dispatchMessage(msg, self.getId())
                        self.distributeMessage(msg)
                except Exception as err:
                    print("ActiveMQ message was unable to be parsed")
                    logError(err, stack=traceback.format_exc())
 def __init__(self, DictionaryLocation):
     self._dictionary = {}
     try:
         self._dictionary = self.loadDictionary(DictionaryLocation)
     except Exception, e:
         logError(e)
Exemplo n.º 12
0
 def __init__(self, DictionaryLocation):
     self._dictionary = {}
     try:
         self._dictionary = self.loadDictionary(DictionaryLocation)
     except Exception, e:
         logError(e)