def run(self):
        """Update the bugtask target name caches."""
        self.logger.info("Updating targetname cache of bugtasks.")
        loop = BugTaskTargetNameCachesTunableLoop(self.transaction, self.logger)

        # We use the LoopTuner class to try and get an ideal number of
        # bugtasks updated for each iteration of the loop (see the
        # LoopTuner documentation for more details).
        loop_tuner = LoopTuner(loop, 2)
        loop_tuner.run()

        self.logger.info("Updated %i target names." % loop.total_updated)
        self.logger.info("Finished updating targetname cache of bugtasks.")
    def run(self):
        """Update the bugtask target name caches."""
        self.logger.info("Updating targetname cache of bugtasks.")
        loop = BugTaskTargetNameCachesTunableLoop(self.transaction,
                                                  self.logger)

        # We use the LoopTuner class to try and get an ideal number of
        # bugtasks updated for each iteration of the loop (see the
        # LoopTuner documentation for more details).
        loop_tuner = LoopTuner(loop, 2)
        loop_tuner.run()

        self.logger.info("Updated %i target names." % loop.total_updated)
        self.logger.info("Finished updating targetname cache of bugtasks.")
Пример #3
0
    def processCVEXML(self, cve_xml):
        """Process the CVE XML file.

        :param cve_xml: The CVE XML as a string.
        """
        dom = cElementTree.fromstring(cve_xml)
        items = dom.findall(CVEDB_NS + 'item')
        if len(items) == 0:
            raise LaunchpadScriptFailure("No CVEs found in XML file.")
        self.logger.info("Updating database...")

        # We use Looptuner to control the ideal number of CVEs
        # processed in each transaction, during at least 2 seconds.
        loop = CveUpdaterTunableLoop(items, self.txn, self.logger)
        loop_tuner = LoopTuner(loop, 2)
        loop_tuner.run()
Пример #4
0
    def processCVEXML(self, cve_xml):
        """Process the CVE XML file.

        :param cve_xml: The CVE XML as a string.
        """
        dom = cElementTree.fromstring(cve_xml)
        items = dom.findall(CVEDB_NS + 'item')
        if len(items) == 0:
            raise LaunchpadScriptFailure("No CVEs found in XML file.")
        self.logger.info("Updating database...")

        # We use Looptuner to control the ideal number of CVEs
        # processed in each transaction, during at least 2 seconds.
        loop = CveUpdaterTunableLoop(items, self.txn, self.logger)
        loop_tuner = LoopTuner(loop, 2)
        loop_tuner.run()
Пример #5
0
    def test_cleanup_exception_on_success(self):
        """Main task succeeded but cleanup failed.

        Exception from cleanup raised.
        """
        log_file = StringIO()
        loop = FailingLoop(fail_cleanup=True)
        tuner = LoopTuner(loop, 5, log=FakeLogger(log_file))
        self.assertRaises(CleanupException, tuner.run)
        self.assertEqual(log_file.getvalue(), "")
Пример #6
0
    def test_cleanup_exception_on_failure(self):
        """Main task failed and cleanup also failed.

        Exception from cleanup is logged.
        Original exception from main task is raised.
        """
        log_file = StringIO()
        loop = FailingLoop(fail_main=True, fail_cleanup=True)
        tuner = LoopTuner(loop, 5, log=FakeLogger(log_file))
        self.assertRaises(MainException, tuner.run)
        self.assertEqual(log_file.getvalue().strip(),
                         "ERROR Unhandled exception in cleanUp")