コード例 #1
0
ファイル: context.py プロジェクト: unnch/spell-sat
    def start(self):
        LOG("Loading procedures for this context", level=LOG_INIT)
        ProcedureManager.instance().setup(self.ctxName)

        LOG("Setting up GUI channel", level=LOG_INIT)
        # Setup the Gui io channel
        self.__guiIFC.connect(888, 0, self.processGuiMessage,
                              self.processGuiRequest, self.guiConnectionLost)
        self.__guiIFC.start()

        LOG("Connecting to listener", level=LOG_INIT)
        # Setup the Listener io channel
        self.__lstIFC.connect("localhost", self.listenerPort,
                              self.processListenerMessage,
                              self.processListenerRequest,
                              self.lstConnectionLost)

        LOG("Using listening port: " + str(self.__guiIFC.port), level=LOG_INIT)
        portMsg = MsgHelper.createMessage(LstMessages.MSG_CONTEXT_OPEN)
        portMsg[LstMessages.FIELD_CTX_NAME] = self.ctxName
        portMsg[LstMessages.FIELD_CTX_PORT] = str(self.__guiIFC.port)
        portMsg.setSender("CTX")
        portMsg.setReceiver("LST")
        self.__lstIFC.sendMessage(portMsg)
        LOG("Ready", level=LOG_INIT)
        sys.stderr.write("*********************************************\n")
        sys.stderr.write("      SPEL Context (" + ctxName + ") Ready \n")
        sys.stderr.write("*********************************************\n")
コード例 #2
0
    def buildExecutorInfo(self, procId, resp ):
        
        executor = self.getExecutor(procId)

        pname = ProcedureManager.instance().getProcedure(procId).name()
        
        if executor is None:
            txt = "No such executor: " + repr(procId)
            reason = " "
            resp[ExcMessages.FIELD_PROC_ID] = procId
            resp[ExcMessages.FIELD_PARENT_PROC] = " "
            resp[ExcMessages.FIELD_PROC_NAME] = pname
            resp[ExcMessages.FIELD_ASRUN_NAME] = " "
            resp[ExcMessages.FIELD_LOG_NAME] = " "
            resp[ExcMessages.FIELD_EXEC_PORT] = "0"
            resp[ExcMessages.FIELD_EXEC_STATUS] = server.executor.status.UNINIT
            resp[ExcMessages.FIELD_CONDITION] = ""
            resp[ExcMessages.FIELD_GUI_LIST] = " "
            resp[ExcMessages.FIELD_GUI_CONTROL] = " "
            resp[CtxMessages.FIELD_OPEN_MODE] = " "
            resp[ExcMessages.FIELD_LINE] = "0"
            resp[ExcMessages.FIELD_CSP] = procId
        else:
            control = executor.getControllingClient()
            if control is None:
                control = " "

            guiList = ""
            for gui in executor.getMonitoringClients():
                if len(guiList)>0: guiList = guiList + ","
                guiList = guiList + str(gui)
            
            resp[ExcMessages.FIELD_PROC_ID] = procId
            resp[ExcMessages.FIELD_PARENT_PROC] = executor.getParent()
            resp[ExcMessages.FIELD_PROC_NAME] = pname
            resp[ExcMessages.FIELD_ASRUN_NAME] = executor.getAsRunFile()
            resp[ExcMessages.FIELD_LOG_NAME] = executor.getLogFile()
            resp[ExcMessages.FIELD_EXEC_PORT] = executor.getPort()
            resp[ExcMessages.FIELD_EXEC_STATUS] = executor.getStatus()
            resp[ExcMessages.FIELD_CONDITION] = executor.getCondition()
            resp[ExcMessages.FIELD_GUI_LIST] = guiList
            resp[ExcMessages.FIELD_GUI_CONTROL] = control
            resp[CtxMessages.FIELD_OPEN_MODE] = executor.getOpenMode()
            resp[ExcMessages.FIELD_CSP] = executor.getStackPosition()
            resp[ExcMessages.FIELD_ACTION_LABEL] = executor.getUserActionLabel()
            resp[ExcMessages.FIELD_ACTION_SEV] = executor.getUserActionSeverity()
            aen = executor.getUserActionEnabled()
            if aen:
                resp[ExcMessages.FIELD_ACTION_ENABLED] = "True"
            else:
                resp[ExcMessages.FIELD_ACTION_ENABLED] = "False"
        return resp
コード例 #3
0
ファイル: context.py プロジェクト: seciltabur/spell-sat
    def start(self):
        LOG("Loading procedures for this context", level = LOG_INIT)
        ProcedureManager.instance().setup(self.ctxName)

        LOG("Setting up GUI channel", level = LOG_INIT)
        # Setup the Gui io channel
        self.__guiIFC.connect( 888, 0, self.processGuiMessage, self.processGuiRequest, self.guiConnectionLost)
        self.__guiIFC.start()

        LOG("Connecting to listener", level = LOG_INIT)
        # Setup the Listener io channel
        self.__lstIFC.connect("localhost",self.listenerPort, self.processListenerMessage, self.processListenerRequest, self.lstConnectionLost)

        LOG("Using listening port: " + str(self.__guiIFC.port), level = LOG_INIT)
        portMsg = MsgHelper.createMessage(LstMessages.MSG_CONTEXT_OPEN)
        portMsg[LstMessages.FIELD_CTX_NAME] = self.ctxName
        portMsg[LstMessages.FIELD_CTX_PORT] = str(self.__guiIFC.port)
        portMsg.setSender("CTX")
        portMsg.setReceiver("LST")
        self.__lstIFC.sendMessage(portMsg)
        LOG("Ready", level = LOG_INIT)
        sys.stderr.write("*********************************************\n")
        sys.stderr.write("      SPEL Context (" + ctxName + ") Ready \n")
        sys.stderr.write("*********************************************\n")
コード例 #4
0
    def raiseException(self, ex):
        """
        -----------------------------------------------------------------------
        An exception has been raised by the exec thread
        -----------------------------------------------------------------------
        """
        import traceback
        #We have to retrieve the last TraceBack object in the stack for getting
        # its line
        currentTraceback = sys.exc_info()[2]

        # Return if we cannot gather information about the error (not in proc)
        if not currentTraceback:
            self.__error = True
            self._setStatus(status.ERROR)
            REGISTRY['CIF'].notifyError("Uncaught exception: " + repr(ex), ' ')
            return

        # We extract the traceback elements to process it our way
        processedTraceback = traceback.extract_tb(currentTraceback)
        # Remove elements from the ptrace which are not part of our procedure
        processedTraceback = filter(
            lambda x: ProcedureManager.instance().isProcDir(x[0]),
            processedTraceback)
        lastTb = processedTraceback[-1]

        while (currentTraceback.tb_next != None):
            currentTraceback = currentTraceback.tb_next
        separator = ':'
        #TODO Manipulate the stack message for showing the exception messange
        #in a more natural way
        stackMessage = self.__callstack.getStack()
        #stackMessage is represented this way Proc1:23:Proc2:56
        #We want to get the two last elements
        lastInvocation = str(stackMessage).split(separator)[-2:]
        try:
            lastInvocationString = '(Procedure ' + str(
                lastInvocation[-2]).replace('$', '') + ', Line ' + str(
                    lastTb[1]) + ')'
        except:
            lastInvocationString = 'Unknown location: ' + repr(stackMessage)
        #Notify the error and set the status
        message = lastInvocationString + ': ' + str(ex)
        self.__error = True
        self._setStatus(status.ERROR)
        sys.stderr.write(message)
        REGISTRY['CIF'].notifyError(message, ' ')
コード例 #5
0
ファイル: callstack.py プロジェクト: seciltabur/spell-sat
 def event_call(self, file, line, name, frame, args):
     
     # The procedure is loaded (first time)
     if len(self.__stack) == 0:
         self.__stack = [ file, str(line) ]
         self.__csp = 0
         self.__knownProcedures += [file]
         self.__updateStack() 
     else:
         # Call to a function, so increase the stack. 
         self.__stack += [ file, str(line) ]
         doNotifyCode = False
         if not file in self.__knownProcedures:
             self.__knownProcedures += [file]
             doNotifyCode = True
             
         # If the permanent flag is on and sticky is false, enable it
         if self.__permanent and not self.__sticky:
             self.setSticky(True)
             
         # If we are stepping over, do not change the marker position
         # otherwise move the marker up.
         if not self.__sticky:
             self.__csp = len(self.__stack)
             
         self.__updateStack() 
         if doNotifyCode:
             
             if file in self.__sources:
                 code = self.__sources[file]
             else:
                 sourceLines = ProcedureManager.instance().getSource(file)
                 code = ""
                 for line in sourceLines:
                     sep = CODE_SEPARATOR
                     add = ""
                     if len(code)==0: sep = ""
                     if len(line)==0: add = " "
                     code += sep + line + add
                 self.__sources[file] = code
                 
             REGISTRY['CIF'].notifyCode( code, self.__stackStr )
         else:
             REGISTRY['CIF'].notifyLine( self.__stackStr, self.__stage )
コード例 #6
0
ファイル: callstack.py プロジェクト: unnch/spell-sat
    def event_call(self, file, line, name, frame, args):

        # The procedure is loaded (first time)
        if len(self.__stack) == 0:
            self.__stack = [file, str(line)]
            self.__csp = 0
            self.__knownProcedures += [file]
            self.__updateStack()
        else:
            # Call to a function, so increase the stack.
            self.__stack += [file, str(line)]
            doNotifyCode = False
            if not file in self.__knownProcedures:
                self.__knownProcedures += [file]
                doNotifyCode = True

            # If the permanent flag is on and sticky is false, enable it
            if self.__permanent and not self.__sticky:
                self.setSticky(True)

            # If we are stepping over, do not change the marker position
            # otherwise move the marker up.
            if not self.__sticky:
                self.__csp = len(self.__stack)

            self.__updateStack()
            if doNotifyCode:

                if file in self.__sources:
                    code = self.__sources[file]
                else:
                    sourceLines = ProcedureManager.instance().getSource(file)
                    code = ""
                    for line in sourceLines:
                        sep = CODE_SEPARATOR
                        add = ""
                        if len(code) == 0: sep = ""
                        if len(line) == 0: add = " "
                        code += sep + line + add
                    self.__sources[file] = code

                REGISTRY['CIF'].notifyCode(code, self.__stackStr)
            else:
                REGISTRY['CIF'].notifyLine(self.__stackStr, self.__stage)
コード例 #7
0
ファイル: controller.py プロジェクト: seciltabur/spell-sat
 def raiseException(self, ex):
     """
     -----------------------------------------------------------------------
     An exception has been raised by the exec thread
     -----------------------------------------------------------------------
     """
     import traceback
     #We have to retrieve the last TraceBack object in the stack for getting
     # its line
     currentTraceback = sys.exc_info()[2]
     
     # Return if we cannot gather information about the error (not in proc)
     if not currentTraceback:
         self.__error = True
         self._setStatus( status.ERROR )
         REGISTRY['CIF'].notifyError("Uncaught exception: " + repr(ex), ' ')
         return
     
     # We extract the traceback elements to process it our way
     processedTraceback = traceback.extract_tb(currentTraceback)
     # Remove elements from the ptrace which are not part of our procedure
     processedTraceback = filter(lambda x : ProcedureManager.instance().isProcDir(x[0]), processedTraceback)
     lastTb = processedTraceback[-1]
        
     while (currentTraceback.tb_next != None):
         currentTraceback = currentTraceback.tb_next
     separator = ':'
     #TODO Manipulate the stack message for showing the exception messange
     #in a more natural way
     stackMessage = self.__callstack.getStack()
     #stackMessage is represented this way Proc1:23:Proc2:56
     #We want to get the two last elements
     lastInvocation = str(stackMessage).split(separator)[-2:]
     try:
         lastInvocationString = '(Procedure ' + str(lastInvocation[-2]).replace('$','') + ', Line ' + str(lastTb[1]) + ')'
     except:
         lastInvocationString = 'Unknown location: ' + repr(stackMessage)
     #Notify the error and set the status
     message = lastInvocationString + ': ' + str(ex)
     self.__error = True
     self._setStatus( status.ERROR )
     sys.stderr.write(message)
     REGISTRY['CIF'].notifyError(message, ' ')