コード例 #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
ファイル: Method.py プロジェクト: ACS-Community/ACS
    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
ファイル: EventDispatcher.py プロジェクト: ydc92546169/ACS
    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
ファイル: EventDispatcher.py プロジェクト: ACS-Community/ACS
    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