当前位置: 首页>>代码示例>>Python>>正文


Python lib.Util类代码示例

本文整理汇总了Python中lib.Util的典型用法代码示例。如果您正苦于以下问题:Python Util类的具体用法?Python Util怎么用?Python Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

    def delete(self, testCaseId):
        
        NsmUtil.printHeadLine2('START: delete test case ' + testCaseId)

        self.deleteUrl = self.uid + '/delete'
        nameDash = self.createName.replace(' ', '-')
        debugDeleteFilePath = Define._PathResponseDelete + '/' + nameDash + '-delete-' + testCaseId + '.xml'
        self.logger.info('delete url: ' + self.deleteUrl)
        
        status = None
        if (self.isOffLine):
            self.logger.debug('get delete task from file: ' + debugDeleteFilePath)
            self.deleteTaskXml = Util.readFile(debugDeleteFilePath)
            
            myTask = Task(self.deleteTaskXml)
            status = myTask.checkResult()
            self.deleteTaskXml = myTask.taskXml
        else:
            self.deleteTaskXml = HttpUtil.doPost(self.deleteUrl, Define._credential)
            self.logger.debug('write pending delete task to file: ' + debugDeleteFilePath + '-pending.xml')
            Util.writeFile(debugDeleteFilePath+'-pending.xml', self.deleteTaskXml)
            
            myTask = Task(self.deleteTaskXml)
            status = myTask.checkResult()
            self.deleteTaskXml = myTask.taskXml
    
            self.logger.info('write to file ' + debugDeleteFilePath)
            #self.logger.info(self.deleteTaskXml)
            Util.writeFile(debugDeleteFilePath, self.deleteTaskXml)
             
        NsmUtil.printHeadLine2('END: delete test case ' + testCaseId)
        return status
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:32,代码来源:element.py

示例2: populateCreateDescription

 def populateCreateDescription(self, description):
     if not description:
         try:
             self.createDescription = self.requestParams['description']
         except KeyError:
             self.createDescription = Util.getXpathValue(Util.readFile(self.requestBodyFilePath), XPath._RequestBodyDescription)
             if (self.createDescription.startswith('$')):
                 raise ValueError('request body description [' + self.createDescription + '] is not defined in file ' + self.requestBodyFilePath)
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:8,代码来源:element.py

示例3: __init__

 def __init__(self, catalog, name=None, description=None, requestBodyFileName=None, requestParams=None):
     '''
     Constructor
     '''        
     Element.__init__(self)
     self.createName = name
     self.getCatalogUrl = Util.getXpathValue(catalog, XPath._TopIndexCatalogLinkHref)
     self.getProviderListUrl = Util.getXpathValue(catalog, XPath._TopIndexListProviderLinkHref)
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:8,代码来源:top.py

示例4: populateCreateName

 def populateCreateName(self, name):
     if not name:
         try:
             self.createName = self.requestParams['name']
         except KeyError:
             self.createName = Util.getXpathValue(Util.readFile(self.requestBodyFilePath), XPath._RequestBodyName)
             if (self.createName.startswith('$')):
                 raise ValueError('request body name [' + self.createName + '] is not defined in file ' + self.requestBodyFilePath)
     self.logger.info('-----------> element object name or create name: ' + self.createName)
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:9,代码来源:element.py

示例5: saveUid

 def saveUid(uidList):
     line = ''
     NsmUtil.__logger.debug('')
     for pair in uidList:
         objectUid   = pair[0]
         objectClass = pair[1]
         objectName  = pair[2]
         NsmUtil.__logger.debug('uid: ' + objectUid + ' ------> ' + objectClass + ' [' + objectName + ']')
         line += objectUid + ';' + objectClass + ';' + objectName + "\n"
     Util.writeFile(Define._PathUidDefault, line)
     NsmUtil.__logger.debug('')
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:11,代码来源:nsmUtil.py

示例6: getIpAddressListByPairList

 def getIpAddressListByPairList(ipAddressPairList, count):
     
     index = 0
     returnIpAddressList = []
     for onePair in ipAddressPairList:
         ipv4Start = onePair[0]
         ipv4End = onePair[1]
         ipv4StartNumber = Util.dottedQuadToNum(ipv4Start)
         ipv4EndNumber = Util.dottedQuadToNum(ipv4End)
         for oneIpNumber in range(ipv4StartNumber, ipv4EndNumber+1):
             returnIpAddressList.append(Util.numToDottedQuad(oneIpNumber))
             index += 1
             if index == count: return returnIpAddressList
     return None
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:14,代码来源:nsmUtil.py

示例7: verifyCreate

 def verifyCreate(goldenFilePath, currentFilePath):
     goldenStr  = Util.readFile(goldenFilePath)
     currentStr = Util.readFile(currentFilePath)
     
     goldenStr  = ResponseVerification.formalize(goldenStr)
     currentStr = ResponseVerification.formalize(currentStr)
     
     if goldenStr == currentStr:
         ResponseVerification.__logger.info('Response Verification test result: PASSED')
         return True
     else:
         ResponseVerification.__logger.info('golden:  ' + goldenStr)
         ResponseVerification.__logger.info('current: ' + currentStr)
         ResponseVerification.__logger.info('Response Verification test result: FAILED')
         return False
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:15,代码来源:responseVerification.py

示例8: __init__

 def __init__(self, taskXml):
     '''
     Constructor
     '''
     self.logger = Util.getLogger(self.__class__.__name__)
     self._loopCount = 10
     self.taskXml = taskXml
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:7,代码来源:task.py

示例9: validateByFile

def validateByFile(xsdFilePaths, xmlFilePath):
    xsdStreamSources = []
    for xsdFilePath in xsdFilePaths:
        xsdStreamSource = StreamSource(FileReader(xsdFilePath))
        xsdStreamSources.append(xsdStreamSource)
    xmlStreamSource = StreamSource(StringReader(Util.readFile(xmlFilePath)))
    return validate(xsdStreamSources, xmlStreamSource)
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:7,代码来源:XmlSchemaValidator.py

示例10: parseCatalog

 def parseCatalog(self):
     for relKey in IpReservation._linkRelKeys:
         evalXpath = XPath._LinkIpReservation
         evalXpath = evalXpath.replace('${rel}', relKey)
         link = Util.getXpathValue(self.catalogXml, evalXpath)
         self.logger.info('Link of ' + relKey + ': ' + link)
         self.relLinkDictionary[relKey] = link
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:7,代码来源:ipAddressPool.py

示例11: __init__

 def __init__(self, catalog, name=None, description=None, requestFileName='default-private-edge-zone.xml', requestParams=None):
     self.logger = Util.getLogger(self.__class__.__name__)
     Element.__init__(self)
     Element.setCatalogMatchParameter(self, PrivateEdgeZone._catalogServiceOfferingType, PrivateEdgeZone._catalogServiceOfferingName, PrivateEdgeZone._catalogLinkTitle)
     Element.setCreateParameter(self, name, description, requestFileName, requestParams)        
     Element.parseCatalog(self, catalog)
     
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:6,代码来源:privateEdgeZone.py

示例12: __init__

 def __init__(self):
     self._logger = Util.getLogger(self.__class__.__name__)
     self._topName = 'My Default Top'
     self._thisObject = None
     self._dataStore = {}
     self._uidList = []
     self._resultList = []
     self._totalTestCase = 0
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:8,代码来源:test-devkit.py

示例13: getRequest

 def getRequest(self, getUrl, debugDetailFilePath):
         
     getResponseXml = None
     self.logger.info('get request url: ' + getUrl)
     if (self.isOffLine):
         self.logger.debug('get response from file: ' + debugDetailFilePath)
         getResponseXml = Util.readFile(debugDetailFilePath)
     else:    
         getResponseXml = HttpUtil.doGet(getUrl, Define._credential)
         self.logger.debug('write response to file: ' + debugDetailFilePath)
         Util.writeFile(debugDetailFilePath, getResponseXml)
     
     '''
     uid = Util.getXpathValue(getResponseXml, XPath._DetailUid)
     self.logger.info('uid: ' + uid)
     getCatalogUrl = Util.getXpathValue(getResponseXml, XPath._DetailLinkCatalog)
     return getCatalogUrl
     '''
     return getResponseXml
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:19,代码来源:element.py

示例14: getList

 def getList(self, getUrl, listClassName, testCaseId):
     
     NsmUtil.printHeadLine2('START: get ' + listClassName + ' list test case ' + testCaseId)
     
     nameDash = self.createName.replace(' ', '-')
     debugDetailFilePath = Define._PathResponseCreateDefault + '/' + nameDash + '-' + listClassName + '-list-' + testCaseId + '.xml'
     
     getResponseXml = None
     self.logger.info('get list url: ' + getUrl)
     if (self.isOffLine):
         self.logger.debug('get ' + listClassName + ' list response from file: ' + debugDetailFilePath)
         getResponseXml = Util.readFile(debugDetailFilePath)
     else:    
         getResponseXml = HttpUtil.doGet(getUrl, Define._credential)
         self.logger.debug('write ' + listClassName + ' list response to file: ' + debugDetailFilePath)
         Util.writeFile(debugDetailFilePath, getResponseXml)
     
     NsmUtil.printHeadLine2('END: get ' + listClassName + ' list test case ' + testCaseId)
     return getResponseXml
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:19,代码来源:element.py

示例15: getCatalog

 def getCatalog(self, testCaseId='000'):
     
     NsmUtil.printHeadLine2('START: get catalog test case ' + testCaseId)
     
     self.logger.debug('get catalog request: ' + self.getCatalogUrl)
     nameDash = self.createName.replace(' ', '-')
     debugCatalogFilePath = Define._PathResponseCreateDefault + '/' + nameDash + '-catalog-' + testCaseId + '.xml'
     
     if (self.isOffLine):
         self.logger.debug('get catalog from file: ' + debugCatalogFilePath)
         self.catalogXml = Util.readFile(debugCatalogFilePath)
     else:
         self.catalogXml = HttpUtil.doGet(self.getCatalogUrl, Define._credential) if self.getCatalogUrl and self.getCatalogUrl != '' else None
         if self.catalogXml:
             self.logger.debug('catalog output file: ' + debugCatalogFilePath)
             Util.writeFile(debugCatalogFilePath, self.catalogXml)
         
     NsmUtil.printHeadLine2('END: get catalog test case ' + testCaseId)
     return self.catalogXml
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:19,代码来源:element.py


注:本文中的lib.Util类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。