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
def openExecutor(self, procId, clientKey, clientMode, openMode={}, arguments=None, condition=None, parentId=None): ctxInfo = Config.instance().getContextConfig(self.ctxName) driverName = ctxInfo.getDriver() maxProcs = int( Config.instance().getDriverConfig(driverName).getMaxProcs()) if maxProcs > 0: activeProcs = self.getNumActiveProcs() if (activeProcs >= maxProcs): raise ContextError( "Could not launch executor. Maximum number of processes reached (" + str(maxProcs) + ")") success = False LOG("Requested opening executor " + repr(procId), level=LOG_PROC) executor = self.createExecutor(procId) # Update the proc id with the instance number procId = executor.getProcId() # Get configuration defaults for open mode and update it #TODO: get open mode defaults from config useOpenMode = {Automatic: False, Visible: True, Blocking: True} useOpenMode.update(openMode) # Set the controlling client key if the procedure is visible if useOpenMode[Visible] == True: clientInfo = self.getClient(clientKey) executor.addClient(clientInfo, True) clientInfo.addExecutor(procId) clientInfo.setMode(clientMode) LOG("Launching executor " + repr(procId) + " in mode " + repr(useOpenMode), level=LOG_PROC) if arguments: executor.setArguments(arguments) if condition: executor.setCondition(condition) if parentId: executor.setParent(parentId) # Set the open mode and open the executor executor.setOpenMode(useOpenMode) executor.start() success = executor.waitForOpen() LOG("Executor launched (" + repr(success) + ")", level=LOG_PROC) if not success: error, reason = executor.getError() self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE) self.killExecutor(procId) self.clearExecutor(procId) raise ContextError("Could not launch executor", error + ":" + reason) else: initialStatus = executor.getStatus() if initialStatus == server.executor.status.ERROR: error, reason = executor.getError() self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE) self.killExecutor(procId) self.clearExecutor(procId) raise ContextError("Executor failed startup", error + ":" + reason) else: pid = executor.getExecutorPid() self.__executorsRegistry.addProcess(pid, procId) LOG("Notifying executor open", level=LOG_PROC) self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_OPEN, clientKey, clientMode) LOG("Open finished") return
def openExecutor(self, procId, clientKey, clientMode, openMode = {}, arguments = None, condition = None, parentId = None): ctxInfo = Config.instance().getContextConfig(self.ctxName) driverName = ctxInfo.getDriver() maxProcs = int(Config.instance().getDriverConfig(driverName).getMaxProcs()) if maxProcs>0: activeProcs = self.getNumActiveProcs() if (activeProcs >= maxProcs): raise ContextError("Could not launch executor. Maximum number of processes reached (" + str(maxProcs) + ")") success = False LOG("Requested opening executor " + repr(procId), level = LOG_PROC) executor = self.createExecutor(procId) # Update the proc id with the instance number procId = executor.getProcId() # Get configuration defaults for open mode and update it #TODO: get open mode defaults from config useOpenMode = {Automatic:False,Visible:True,Blocking:True} useOpenMode.update(openMode) # Set the controlling client key if the procedure is visible if useOpenMode[Visible] == True: clientInfo = self.getClient(clientKey) executor.addClient(clientInfo, True) clientInfo.addExecutor(procId) clientInfo.setMode(clientMode) LOG("Launching executor " + repr(procId) + " in mode " + repr(useOpenMode), level = LOG_PROC) if arguments: executor.setArguments(arguments) if condition: executor.setCondition(condition) if parentId: executor.setParent(parentId) # Set the open mode and open the executor executor.setOpenMode(useOpenMode) executor.start() success = executor.waitForOpen() LOG("Executor launched (" + repr(success) + ")", level = LOG_PROC) if not success: error,reason = executor.getError() self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE) self.killExecutor(procId) self.clearExecutor(procId) raise ContextError("Could not launch executor",error + ":" + reason) else: initialStatus = executor.getStatus() if initialStatus == server.executor.status.ERROR: error,reason = executor.getError() self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE) self.killExecutor(procId) self.clearExecutor(procId) raise ContextError("Executor failed startup",error + ":" + reason) else: pid = executor.getExecutorPid() self.__executorsRegistry.addProcess(pid,procId) LOG("Notifying executor open", level = LOG_PROC) self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_OPEN, clientKey, clientMode) LOG("Open finished") return