def setUp(self):
        """
        Starts the component whose id matches the one stored in the IMPL_ID
        """
        
        signal.signal(signal.SIGINT, self.tearDown)
        signal.signal(signal.SIGTERM, self.tearDown)
        signal.signal(signal.SIGQUIT, self.tearDown)
        
        global SOFT_PKG
        global IMPL_ID
        self.comp_obj = None
        self.comp = None
        # Use the globals by default
        self.impl = IMPL_ID
        self.spd_file = SOFT_PKG
        self.spd = SPDParser.parse(SOFT_PKG)
        
        try:
            self.prf_file = self.spd.get_propertyfile().get_localfile().get_name()
            if (self.prf_file[0] != '/'):
                self.prf_file = os.path.join(os.path.dirname(self.spd_file), self.prf_file)
            self.prf = PRFParser.parse(self.prf_file)
        except:
            self.prf_file = None
            self.prf = None
        
        self.scd_file = self.spd.get_descriptor().get_localfile().get_name()
        if (self.scd_file[0] != '/'):
            self.scd_file = os.path.join(os.path.dirname(self.spd_file), self.scd_file)
        self.scd = SCDParser.parse(self.scd_file)

        # create a map between prop ids and names
        if self.prf:
            self._props = prop_helpers.getPropNameDict(self.prf)
    def runConfigurationTest(self, spd_file, prf_file):
        """
        Tests all the properties defined in the PRF file and attempts to 
        configure each property.  If the property is of kind 'configure' and 
        the mode is not readonly, then it compares the results with what is
        expected.  Otherwise it expects an exception to be thrown
        
        Inputs:
            <spd_file>    The component's SPD file
            <prf_file>    The component's properties file
        """
        self.launch()
        prf = PRFParser.parse(prf_file)
        props = prf.get_simple()
        int_off = 1
        frac_off = 1.0
        # iterating through all the properties
        for prop in props:
            id_ = prop.get_id()
            mode_ = prop.get_mode()
            val_ = prop.get_value()
            type_ = prop.get_type()

            kinds = prop.get_kind()
            is_configurable = False

            # check each kind to see if at least one of them is configure
            for kind in kinds:
                kind_type = kind.get_kindtype()
                if kind_type == 'configure':
                    is_configurable = True
                    break
            # generate some bogus value
            if type_ == 'double' or type_ == 'float':
                new_val = frac_off + float(val_)
            elif type_ == 'integer' or type_ == 'long':
                new_val = int_off + int(val_)
            else:
                new_val = '%s_%d' % (val_, int_off)

            conf_prop = CF.DataType(id=str(id_), value=any.to_any(new_val))

            # if it can be configured, test that is the case
            if is_configurable and mode_ != 'readonly':
                self.comp_obj.configure([conf_prop])
                q_value = self.comp_obj.query([conf_prop])
                self.assertEqual(len(q_value), 1)
                self.assertEqual(conf_prop.id, q_value[0].id)
                self.assertEqual(conf_prop.value._v, q_value[0].value._v)

            # this property should be be configurable
            else:
                try:
                    self.comp_obj.configure([conf_prop])
                    self.assertFalse()
                except:
                    # Got an expected error, so we should continue
                    continue
 def runConfigurationTest(self, spd_file, prf_file):
     """
     Tests all the properties defined in the PRF file and attempts to 
     configure each property.  If the property is of kind 'configure' and 
     the mode is not readonly, then it compares the results with what is
     expected.  Otherwise it expects an exception to be thrown
     
     Inputs:
         <spd_file>    The component's SPD file
         <prf_file>    The component's properties file
     """        
     self.launch()
     prf = PRFParser.parse(prf_file)
     props = prf.get_simple()
     int_off = 1
     frac_off = 1.0
     # iterating through all the properties
     for prop in props:
         id_ = prop.get_id()
         mode_ = prop.get_mode()
         val_  = prop.get_value()
         type_ = prop.get_type()
         
         kinds = prop.get_kind()
         is_configurable = False
         
         # check each kind to see if at least one of them is configure
         for kind in kinds:
             kind_type = kind.get_kindtype()
             if kind_type == 'configure':
                 is_configurable = True
                 break
         # generate some bogus value
         if type_ == 'double' or type_ == 'float':
             new_val = frac_off + float(val_)
         elif type_ == 'integer' or type_ == 'long':
             new_val = int_off + int(val_)
         else:
             new_val = '%s_%d' % (val_, int_off)
         
         conf_prop = CF.DataType(id=str(id_), value=any.to_any(new_val))                
         
         # if it can be configured, test that is the case                                        
         if is_configurable and mode_ != 'readonly':
             self.comp_obj.configure([conf_prop])
             q_value = self.comp_obj.query([conf_prop])
             self.assertEqual(len(q_value), 1)
             self.assertEqual(conf_prop.id, q_value[0].id)
             self.assertEqual(conf_prop.value._v, q_value[0].value._v)
         
         # this property should be be configurable
         else:
             try:
                 self.comp_obj.configure([conf_prop])
                 self.assertFalse()
             except:
                 # Got an expected error, so we should continue
                 continue
    def __init__(
        self,
        name,
        implementation,
        outputDir=".",
        generator="cpp.component.pull",
        spdTemplateFile=OSSIEHOME + DEFAULT_SPD_TEMPLATE,
        scdTemplateFile=OSSIEHOME + DEFAULT_SCD_TEMPLATE,
        prfTemplateFile=OSSIEHOME + DEFAULT_PRF_TEMPLATE,
        loggingConfigUri=None,
    ):
        """
        Create a resource with no ports/properties.  Use helper methods to add
        additional elements.

        Note, "implementation" argument must be "cpp", "java", or "python"

        """

        SoftPackage.__init__(self, name, implementation, outputDir)

        self.spd = spd.parse(spdTemplateFile)
        self.scd = scd.parse(scdTemplateFile)
        self.prf = prf.parse(prfTemplateFile)

        self._setImplementation()
        self._setNameInSpd()
        self._setPropertyFileInSpd()
        self._setDescriptorInSpd()

        self._createWavedevContent(generator=generator)

        if loggingConfigUri:
            self.addSimpleProperty(
                id="LOGGING_CONFIG_URI",
                value=loggingConfigUri,
                type="string",
                complex=False,
                kindtypes=["configure", "execparam"],
            )
    def __init__(self,
                 name,
                 implementation,
                 outputDir=".",
                 generator="cpp.component.pull",
                 spdTemplateFile=OSSIEHOME + DEFAULT_SPD_TEMPLATE,
                 scdTemplateFile=OSSIEHOME + DEFAULT_SCD_TEMPLATE,
                 prfTemplateFile=OSSIEHOME + DEFAULT_PRF_TEMPLATE,
                 loggingConfigUri=None):
        '''
        Create a resource with no ports/properties.  Use helper methods to add
        additional elements.

        Note, "implementation" argument must be "cpp", "java", or "python"

        '''

        SoftPackage.__init__(self, name, implementation, outputDir)

        self.spd = spd.parse(spdTemplateFile)
        self.scd = scd.parse(scdTemplateFile)
        self.prf = prf.parse(prfTemplateFile)

        self._setImplementation()
        self._setNameInSpd()
        self._setPropertyFileInSpd()
        self._setDescriptorInSpd()

        self._createWavedevContent(generator=generator)

        if loggingConfigUri:
            self.addSimpleProperty(id="LOGGING_CONFIG_URI",
                                   value=loggingConfigUri,
                                   type="string",
                                   complex=False,
                                   kindtypes=["configure", "execparam"])

        self.setComponentType('resource')
        self.setComponentRepid('IDL:CF/Resource:1.0')
    def setUp(self):
        """
        Starts the component whose id matches the one stored in the IMPL_ID
        """

        signal.signal(signal.SIGINT, self.tearDown)
        signal.signal(signal.SIGTERM, self.tearDown)
        signal.signal(signal.SIGQUIT, self.tearDown)

        global SOFT_PKG
        global IMPL_ID
        self.comp_obj = None
        self.comp = None
        # Use the globals by default
        self.impl = IMPL_ID
        self.spd_file = SOFT_PKG
        self.spd = SPDParser.parse(SOFT_PKG)

        try:
            self.prf_file = self.spd.get_propertyfile().get_localfile(
            ).get_name()
            if (self.prf_file[0] != '/'):
                self.prf_file = os.path.join(os.path.dirname(self.spd_file),
                                             self.prf_file)
            self.prf = PRFParser.parse(self.prf_file)
        except:
            self.prf_file = None
            self.prf = None

        self.scd_file = self.spd.get_descriptor().get_localfile().get_name()
        if (self.scd_file[0] != '/'):
            self.scd_file = os.path.join(os.path.dirname(self.spd_file),
                                         self.scd_file)
        self.scd = SCDParser.parse(self.scd_file)

        # create a map between prop ids and names
        if self.prf:
            self._props = prop_helpers.getPropNameDict(self.prf)
Exemplo n.º 7
0
     print "Could not parse", file_entry
     continue
 comp['name'] = str(tmp.get_name())
 components.append(str(tmp.get_name()))
 if tmp.description == None:
     comp['description'] = ''
 else:
     comp['description'] = str(tmp.description)
 if tmp.descriptor == None:
     comp['SCD'] = None
 else:
     comp['SCD'] = _SCDParser.parse(dir_entry+str(tmp.descriptor.localfile.get_name()))
 if tmp.propertyfile == None:
     comp['PRF'] = None
 else:
     comp['PRF'] = _PRFParser.parse(dir_entry+str(tmp.propertyfile.localfile.get_name()))
 comp['implementations'] = []
 for impl in tmp.implementation:
     dep = ''
     procs = ''
     first = True
     if impl.dependency != None:
         for dependency in impl.dependency:
             if dependency.softpkgref != None:
                 if first:
                     dep = str(dependency.softpkgref.localfile.get_name())
                     first = False
                 else:
                     dep += ',' + str(dependency.softpkgref.localfile.get_name())
     first = True
     for proc in impl.processor:
Exemplo n.º 8
0
     continue
 comp['name'] = str(tmp.get_name())
 components.append(str(tmp.get_name()))
 if tmp.description == None:
     comp['description'] = ''
 else:
     comp['description'] = str(tmp.description)
 if tmp.descriptor == None:
     comp['SCD'] = None
 else:
     comp['SCD'] = _SCDParser.parse(
         dir_entry + str(tmp.descriptor.localfile.get_name()))
 if tmp.propertyfile == None:
     comp['PRF'] = None
 else:
     comp['PRF'] = _PRFParser.parse(
         dir_entry + str(tmp.propertyfile.localfile.get_name()))
 comp['implementations'] = []
 for impl in tmp.implementation:
     dep = ''
     procs = ''
     first = True
     if impl.dependency != None:
         for dependency in impl.dependency:
             if dependency.softpkgref != None:
                 if first:
                     dep = str(dependency.softpkgref.localfile.get_name())
                     first = False
                 else:
                     dep += ',' + str(
                         dependency.softpkgref.localfile.get_name())
     first = True