示例#1
0
    def processAllResources(self, feedType):
        self.rqmProjectArea = self.projectAlias.split('/').pop()
        LOG.info("processAllResources for project %s" % self.rqmProjectArea)
        if self.testPlan is not None:
            tpUrl = self.findPreBuiltObject('testplan', self.testPlan)
        else:
            LOG.info('No test plan specified - processing all TERs in %s' %
                     self.rqmProjectArea)
            tpUrl = None
        if tpUrl:
            historyHeader = ('<hr><p><b>TER History for Test Plan %s</b></p>' %
                             self.testPlan)
        else:
            historyHeader = ('<hr><p><b>TER History for Project %s</b></p>' %
                             self.projectName)
        allHtml = historyHeader
        self.rscCount = 0
        totalCount = 0
        for (resourceUrl, name) in self.getFeedIterator(feedType):
            totalCount += 1
            self.resources[resourceUrl] = name
            _, resourceDom = getResourceFromServer(self.rqmAuthCookie,
                                                   resourceUrl, feedType)
            if resourceDom is not None:
                self.rscCount, histHtml = self.processResource(feedType,
                                                               resourceDom,
                                                               self.rscCount,
                                                               tpUrl)
                if histHtml is not None:
                    allHtml += histHtml
                if self.debugOn:
                    outputFormattedXml(resourceDom)
            if (totalCount / 10) * 10 == totalCount:
                LOG.info('Processed %s TERs' %
                         (totalCount, self.rscCount))

        projToken = self.projectAlias.split('/').pop()
        archHistUrl = JTS_URLMAP['archhistory'] % (self.rqmServerName,
                                                   self.context,
                                                   projToken,
                                                   feedType)

        LOG.info('Collect history of deleted TERs')
        archiveHistory, _ = getResourceFromServer(self.rqmAuthCookie,
                                                  archHistUrl,
                                                  feedType)
        archiveHistory = re.sub('<title type="text"', '<br><b', archiveHistory)
        archiveHistory = re.sub('</title', ': </b', archiveHistory)

        deleteHeader = ('<hr><p><b>Deleted TERs for Project %s</b></p>' %
                        self.projectName)
        allHtml += deleteHeader + archiveHistory
        f = open(self.outputFile, 'w')
        f.write(allHtml)
        f.close()
        LOG.info('TER history published to file %s' % self.outputFile)
示例#2
0
    def processResource(self, feedType, resourceDom, i, testplanUrl):
        elementsNsUrl = getNamespaceUrl('elementsNs')
        qmNsUrl = getNamespaceUrl('qmNs')
        try:
            idNd = resourceDom.find('.//{%s}identifier' % elementsNsUrl)
            idString = idNd.text.split('/').pop()
            tpNd = resourceDom.find('.//{%s}testplan' % qmNsUrl)
            if tpNd is not None:
                tpUrl = tpNd.get('href')
            else:
                tpUrl = None
                LOG.info('**** Could not find test plan url for ter %s' %
                         idNd.text)
                if self.debugOn:
                    outputFormattedXml(resourceDom)

            if testplanUrl is None or testplanUrl == tpUrl:
                i += 1
                projToken = self.projectAlias.split('/').pop()
                historyUrl = JTS_URLMAP['history'] % (self.rqmServerName,
                                                      self.context,
                                                      projToken,
                                                      feedType, idString)
                page, _ = getResourceFromServer(self.rqmAuthCookie, historyUrl,
                                                'history')
                newpage = page.replace('<title', '<p><b>Record %s <br' % i)
                newpage = newpage.replace('</title>', '</b><br>')
                newpage += '<hr>'
                return i, newpage
            else:
                return i, None
        except Exception, e:
            LOG.info('** Exception:  %s' % e)
            sys.exit(1)