示例#1
0
 def BuildAeroflexTag(self,remoteFile):
     print " Build Aeroflex Tag"
     #!Fix: once file not exist
     tree = ET.parse(remoteFile)
     root = tree.getroot()
     factoryIdentity = root.find('FactoryIdentity')
     aeroflex = UT.getelem(root,\
                           'FeatureResource',
                           'resourceId',
                           self.iDict['resourceId'],
                           factoryIdentity)
     
     items = self.iDict.items();items.sort()
     for (key,value) in items:
         if 'interface' == key or\
            'featureModel' == key or\
            'version' == key or\
            'maxNumberOfAllocations' == key or\
            'typeOfAllocation' == key or\
            'resourceId' == key:
             aeroflex.set(key,value)
         else:
             tmpNode = UT.getelem(root,'FeatureAttribute','name',key,aeroflex)
             UT.SetFeatureAttrib(tmpNode,key,value)
     UT.FormatXML(root)
     tree.write(remoteFile, encoding='UTF-8', xml_declaration = True)
示例#2
0
    def BuildENGTag(self,remoteFile):
        print " Build New ENBTag"

        tree = ET.parse(remoteFile)
        root = tree.getroot()
        factoryIdentity = root.find('FactoryIdentity')
        eNodeB = UT.getelem(root,\
                            'FeatureResource',
                            'resourceId',\
                            self.iDict['resourceId'],\
                            factoryIdentity)
        host = UT.getelem(root,\
                          'ConfigurationAttribute',\
                          'name',\
                          'HOST',\
                          eNodeB)
        port = UT.getelem(root,\
                          'ConfigurationAttribute',\
                          'name',\
                          'PORT',\
                          host)
        user = UT.getelem(root,\
                          'ConfigurationAttribute',\
                          'name',\
                          'USER',\
                          port)
        setPrompt = UT.getelem(root,\
                               'ConfigurationAttribute',\
                               'name',\
                               'setPrompt',\
                                user)
        sendCmd = UT.getelem(root,\
                             'ConfigurationAttribute',\
                             'name',\
                             'sendCmd',\
                             setPrompt)
        setRegExPrompt = UT.getelem(root,\
                                    'ConfigurationAttribute',\
                                    'name',\
                                    'setRegExPrompt',\
                                    sendCmd)

        items = self.iDict.items();items.sort()
        for (key,value) in items:            
            if 'interface' == key or\
               'featureModel' == key or\
               'version' == key or\
               'maxNumberOfAllocations' == key or\
               'typeOfAllocation' == key or\
               'resourceId' == key:
                eNodeB.set(key,value)
            elif 'HOST' == key:
                UT.SetFeatureAttrib(host,key,value)
            elif 'PORT' == key:
                UT.SetFeatureAttrib(port,key,value,'INTEGER')
            elif 'USER' == key:
                UT.SetFeatureAttrib(user,key,value)
            elif 'setPrompt' == key:
                UT.SetFeatureAttrib(setPrompt,key,value)
            elif 'sendCmd' == key:
                UT.SetFeatureAttrib(sendCmd,key,value)
            elif 'setRegExPrompt' == key:
                UT.SetFeatureAttrib(setRegExPrompt,key,value)
            elif -1 != key.find('relatedResource') and\
                 value.strip():
                print 'Set relatedResource'
                tmpNode = UT.getelem(root,'FeatureAttribute','name',key,eNodeB)
                UT.SetFeatureAttrib(tmpNode,key,value)
            else:
                tmpNode = UT.getelem(root,'FeatureAttribute','name',key,eNodeB)
                UT.SetFeatureAttrib(tmpNode,key,value)

        UT.FormatXML(root)
        tree.write(remoteFile, encoding='UTF-8', xml_declaration = True)