コード例 #1
0
ファイル: finder_service.py プロジェクト: biicode/bii-server
    def find(self, request, biiout):
        '''
        Params:
            request: FinderRequest
            biiout: biiout
        Rerturns: FinderResult
        '''
        if not request:
            raise ValueError('The find request is empty, nothing to find')

        logger.debug('---------FinderRequest ------------\n%s' % str(request))
        result = FinderResult()
        # Copy unresolved and remove it if find the dependence
        result.unresolved = copy(request.unresolved)

        hypothesis = self._get_hypothesis(request, biiout)
        if not hypothesis:
            biiout.info("No block candidates found")
            return result

        biiout.info("Analyzing compatibility for found dependencies... ")
        '''# primitive combinator variant
        analyzer = CompatibilityAnalyzer(self._store, self._auth_user)
        analysis_result = analyzer.solve(hypothesis)

        # standard constraint variant
        csp = CSPExact(hypothesis, None)
        csp.solveCSP()
        analysis_result = csp.getCompatibleSol()
        logger.info(csp.print_info())'''

        # iterative deepening variant
        it = IterDeep(hypothesis, None, None)
        sol_found, analysis_result = it.start()
        if sol_found:
            logger.info("sol found: {0} iter".format(it.num_iter))

        if analysis_result is None:
            biiout.error("Can't find a compatible solution")
            return result

        self._update_result(analysis_result, request, result, biiout)
        if not result.unresolved:
            if result.resolved:
                biiout.info('All dependencies resolved')
            elif not result.updated:
                biiout.info('Everything was up to date')
        logger.debug('Result %s' % result)
        return result
コード例 #2
0
    def find(self, request, biiout):
        '''
        Params:
            request: FinderRequest
            biiout: biiout
        Rerturns: FinderResult
        '''
        if not request:
            raise ValueError('The find request is empty, nothing to find')

        logger.debug('---------FinderRequest ------------\n%s' % str(request))
        result = FinderResult()
        # Copy unresolved and remove it if find the dependence
        result.unresolved = copy(request.unresolved)

        hypothesis = self._get_hypothesis(request, biiout)
        if not hypothesis:
            biiout.info("No block candidates found")
            return result

        biiout.info("Analyzing compatibility for found dependencies... ")
        '''# primitive combinator variant
        analyzer = CompatibilityAnalyzer(self._store, self._auth_user)
        analysis_result = analyzer.solve(hypothesis)

        # standard constraint variant
        csp = CSPExact(hypothesis, None)
        csp.solveCSP()
        analysis_result = csp.getCompatibleSol()
        logger.info(csp.print_info())'''

        # iterative deepening variant
        it = IterDeep(hypothesis, None, None)
        sol_found, analysis_result = it.start()
        if sol_found:
            logger.info("sol found: {0} iter".format(it.num_iter))

        if analysis_result is None:
            biiout.error("Can't find a compatible solution")
            return result

        self._update_result(analysis_result, request, result, biiout)
        if not result.unresolved:
            if result.resolved:
                biiout.info('All dependencies resolved')
            elif not result.updated:
                biiout.info('Everything was up to date')
        logger.debug('Result %s' % result)
        return result
コード例 #3
0
    def test_apply_result(self):
        # TODO: this is actually a test of find result, move away
        files = {self.block_name + 'main.cpp': '#include "user2/block/sphere.h"'}
        self.hive_manager.process(None, files)

        find_result = FinderResult()
        version = BRLBlock('user2/user2/block/branch') + 3
        d = ReferencedDependencies()
        decl = CPPDeclaration('user2/block/sphere.h')
        d[version][decl].add(BlockCellName('user2/block/sphere.h'))
        find_result.resolved = d

        hive_holder = self.hive_manager.hive_holder
        update_hive_with_find_result(hive_holder, find_result)

        self.assertEqual(2, len(hive_holder.resources))
        self.assertEqual(BlockVersionTable([version]), hive_holder[self.block_name].requirements)
コード例 #4
0
    def test_apply_result(self):
        # TODO: this is actually a test of find result, move away
        files = {
            self.block_name + 'main.cpp': '#include "user2/block/sphere.h"'
        }
        self.hive_manager.process(None, files)

        find_result = FinderResult()
        version = BRLBlock('user2/user2/block/branch') + 3
        d = ReferencedDependencies()
        decl = CPPDeclaration('user2/block/sphere.h')
        d[version][decl].add(BlockCellName('user2/block/sphere.h'))
        find_result.resolved = d

        hive_holder = self.hive_manager.hive_holder
        update_hive_with_find_result(hive_holder, find_result)

        self.assertEqual(2, len(hive_holder.resources))
        self.assertEqual(BlockVersionTable([version]),
                         hive_holder[self.block_name].requirements)
コード例 #5
0
    def test_finder_result(self):
        f = FinderResult()

        s = f.serialize()
        f2 = FinderResult.deserialize(s)
        self.assertEqual(f, f2)
コード例 #6
0
    def test_finder_result(self):
        f = FinderResult()

        s = f.serialize()
        f2 = FinderResult.deserialize(s)
        self.assertEqual(f, f2)