示例#1
0
文件: CDB.py 项目: ydc92546169/ACS
    def getCorbaAttributes(self, xml_obj):
        '''
        Sets the CORBA attributes of this object.
        TODO: rename
        '''
        #attributes is the somewhat formatted data taken from the XML. not really
        #nice enough to work with yet.
        try:
            attributes = xml_obj.SimulatedComponent._corbaAttribute
            if isSequenceType(attributes) == 0:
                attributes = [attributes]
        except:
            return

        #for each method in the list
        for dom in attributes:
            #dictionary defining the method
            temp_dict = {}

            #extract the method name
            attrname = dom.getAttribute('Name')

            #set the timeout
            temp_dict['Timeout'] = float(dom.getAttribute('Timeout'))

            #get the code to be executed yielding a return value
            temp_dict['Value'] = dom.getValue().rstrip().lstrip().split('\n')
            temp_dict['Value'] = getCompLocalNSList(
                self.compname) + temp_dict['Value']
            temp_dict['Value'] = listToCodeObj(temp_dict['Value'], {})

            #save the dictionary
            self.setMethod(attrname, temp_dict)
示例#2
0
    def submit(self, event=None):
        '''
        Method invoked to alter the behavior of some simulated CORBA method/attribute

        Paremeters:
        - event This is ignored!
        '''

        method_name = self.comp_method

        if self.operation_type == "Attributes":
            method_name = "_get_" + method_name

        #create the temporary dictionary
        temp_dict = {
            'Value': None,
            'Timeout': float(self.sleepCounter.getvalue())
        }

        #get the code to be executed yielding a return value
        temp_dict['Value'] = self.st.getvalue().strip().split('\n')
        temp_dict['Value'] = getCompLocalNSList(
            self.comp_name) + temp_dict['Value']
        temp_dict['Value'] = listToCodeObj(temp_dict['Value'], {})

        #store it globally
        getSimProxy(self.comp_name).gui_handler.setMethod(
            method_name, temp_dict)
示例#3
0
    def submit(self, event=None):
        '''
        Method invoked to alter the behavior of some simulated CORBA method/attribute

        Paremeters:
        - event This is ignored!
        '''
        
        method_name = self.comp_method
        
        if self.operation_type=="Attributes":
            method_name = "_get_" + method_name
        
        #create the temporary dictionary
        temp_dict = { 'Value': None,
                      'Timeout': float(self.sleepCounter.getvalue())}
        
        #get the code to be executed yielding a return value
        temp_dict['Value'] = self.st.getvalue().strip().split('\n')
        temp_dict['Value'] = getCompLocalNSList(self.comp_name) + temp_dict['Value']
        temp_dict['Value'] = listToCodeObj(temp_dict['Value'], 
                                           {})
        
        
        
        #store it globally
        getSimProxy(self.comp_name).gui_handler.setMethod(method_name, 
                                                          temp_dict)
示例#4
0
文件: CDB.py 项目: ACS-Community/ACS
    def getCorbaAttributes(self, xml_obj):
        '''
        Sets the CORBA attributes of this object.
        TODO: rename
        '''
        #attributes is the somewhat formatted data taken from the XML. not really
        #nice enough to work with yet.
        try:
            attributes = xml_obj.SimulatedComponent._corbaAttribute
            if isSequenceType(attributes)==0:
                attributes = [ attributes ]
        except:
            return

        #for each method in the list
        for dom in attributes:
            #dictionary defining the method
            temp_dict = {}

            #extract the method name
            attrname= dom.getAttribute('Name')

            #set the timeout
            temp_dict['Timeout'] = float(dom.getAttribute('Timeout'))

            #get the code to be executed yielding a return value
            temp_dict['Value'] = dom.getValue().rstrip().lstrip().split('\n')
            temp_dict['Value'] = getCompLocalNSList(self.compname) + temp_dict['Value']
            temp_dict['Value'] = listToCodeObj(temp_dict['Value'], {})
            
            #save the dictionary
            self.setMethod(attrname, temp_dict)
示例#5
0
文件: CDB.py 项目: ydc92546169/ACS
    def setupLifecyleMethods(self, xml_obj):
        '''
        Sets the lifecyle methods of the object.
        '''
        try:
            dom = xml_obj.SimulatedComponent.initialize
            methname = "initialize"
            temp_dict = {}
            temp_dict['Timeout'] = 0.0

            #get the code to be executed yielding a return value
            temp_dict['Value'] = dom.getValue().rstrip().lstrip().split('\n')
            temp_dict['Value'] = getCompLocalNSList(
                self.compname) + temp_dict['Value']
            temp_dict['Value'] = listToCodeObj(temp_dict['Value'], {})

            #save the dictionary
            self.setMethod(methname, temp_dict)

        except:
            pass

        try:
            dom = xml_obj.SimulatedComponent.cleanUp
            temp_dict = {}
            methname = "cleanUp"
            temp_dict['Timeout'] = 0.0

            #get the code to be executed yielding a return value
            temp_dict['Value'] = dom.getValue().rstrip().lstrip().split('\n')
            temp_dict['Value'] = getCompLocalNSList(
                self.compname) + temp_dict['Value']
            temp_dict['Value'] = listToCodeObj(temp_dict['Value'], {})

            #save the dictionary
            self.setMethod(methname, temp_dict)

        except:
            pass
示例#6
0
文件: CDB.py 项目: ACS-Community/ACS
    def setupLifecyleMethods(self, xml_obj):
        '''
        Sets the lifecyle methods of the object.
        '''
        try:
            dom = xml_obj.SimulatedComponent.initialize
            methname = "initialize"
            temp_dict = {}
            temp_dict['Timeout'] = 0.0
            
            #get the code to be executed yielding a return value
            temp_dict['Value'] = dom.getValue().rstrip().lstrip().split('\n')
            temp_dict['Value'] = getCompLocalNSList(self.compname) + temp_dict['Value']
            temp_dict['Value'] = listToCodeObj(temp_dict['Value'], {})

            #save the dictionary
            self.setMethod(methname, temp_dict)

        except:
            pass
        
        
        try:
            dom = xml_obj.SimulatedComponent.cleanUp
            temp_dict = {}
            methname = "cleanUp"
            temp_dict['Timeout'] = 0.0
            
            #get the code to be executed yielding a return value
            temp_dict['Value'] = dom.getValue().rstrip().lstrip().split('\n')
            temp_dict['Value'] = getCompLocalNSList(self.compname) + temp_dict['Value']
            temp_dict['Value'] = listToCodeObj(temp_dict['Value'], {})

            #save the dictionary
            self.setMethod(methname, temp_dict)

        except:
            pass
示例#7
0
    def eventFunctionHelper(self, event, ifr_id):
        '''
        Returns an event instance or None based off the contents of 
        an _almaEvent or _almaEventReponse XML element (DOM).
        '''
        #here comes the fun part...it might be necessary to dynamically
        #create the object now!
        #get the code to be executed yielding a return value
        try:
            #if the following line of code throws an exception,
            #it's not really a big deal. it just means that
            #no function was defined within the XML element to
            #generate the event instance
            value = event.getValue().rstrip().lstrip().split('\n')

            #this next block is wrapped in a separate try/except
            #because it's possible that the end-user has problems
            #in their function definition.
            try:
                _locals = {}
                #attach all imports to the function definition
                value = getCompLocalNSList(self.comp_name) + value
                #make the code list a function in the _locals namespace
                value = listToCodeObj(value, _locals)
                #create the function
                exec value in globals(), _locals
                #execute the function as well to get the event instance
                exec "joe = stringFunction([])" in globals(), _locals
                event_instance = _locals['joe']

            except Exception, e:
                #the function definition given by the end-user was bad!
                #warn them and schedule dynamic events instead
                acsPrintExcDebug()
                self.logger.logCritical(
                    "Something was wrong within the function definition for the '"
                    + ifr_id + "' event type.")
                self.logger.logInfo(
                    "Will try dynamically creating the event instead.")
                #just rethrow e so the next block catches it
                raise e

        except:
            event_instance = None

        return event_instance
示例#8
0
    def eventFunctionHelper(self, event, ifr_id):
        '''
        Returns an event instance or None based off the contents of 
        an _almaEvent or _almaEventReponse XML element (DOM).
        '''
        #here comes the fun part...it might be necessary to dynamically
        #create the object now!
        #get the code to be executed yielding a return value
        try:
            #if the following line of code throws an exception,
            #it's not really a big deal. it just means that 
            #no function was defined within the XML element to 
            #generate the event instance
            value = event.getValue().rstrip().lstrip().split('\n')
            
            #this next block is wrapped in a separate try/except
            #because it's possible that the end-user has problems
            #in their function definition.
            try:
                _locals = {}
                #attach all imports to the function definition
                value = getCompLocalNSList(self.comp_name) + value
                #make the code list a function in the _locals namespace
                value = listToCodeObj(value, _locals)
                #create the function
                exec value in globals(), _locals
                #execute the function as well to get the event instance
                exec "joe = stringFunction([])" in globals(), _locals
                event_instance = _locals['joe']
                
            except Exception, e:
                #the function definition given by the end-user was bad!
                #warn them and schedule dynamic events instead
                acsPrintExcDebug()
                self.logger.logCritical("Something was wrong within the function definition for the '" + 
                                        ifr_id + 
                                        "' event type.")
                self.logger.logInfo("Will try dynamically creating the event instead.")                    
                #just rethrow e so the next block catches it
                raise e

        except:
            event_instance = None
            
        return event_instance