コード例 #1
0
def resolve_rosdep_key(key, quiet=False):
    sources_loader = SourcesListLoader.create_default(
        sources_cache_dir=get_sources_cache_dir(),
        os_override=None,
        verbose=False)
    lookup = RosdepLookup.create_from_rospkg(sources_loader=sources_loader)
    lookup.verbose = False

    installer_context = create_default_installer_context(verbose=False)

    installer, installer_keys, default_key, \
        os_name, os_version = get_default_installer(
            installer_context=installer_context,
            verbose=False)

    view = lookup.get_rosdep_view(DEFAULT_VIEW_KEY, verbose=False)
    try:
        d = view.lookup(key)
    except KeyError as e:
        sys.stderr.write('Invalid key "{}": {}\n'.format(key, e))
        return

    rule_installer, rule = d.get_rule_for_platform(os_name, os_version,
                                                   installer_keys, default_key)

    installer = installer_context.get_installer(rule_installer)
    resolved = installer.resolve(rule)

    for error in lookup.get_errors():
        if not quiet:
            print('WARNING: %s' % (error), file=sys.stderr)

    return {installer: resolved}
コード例 #2
0
def check_duplicates(sources, os_name, os_codename):
    # output debug info
    print('checking sources')
    for source in sources:
        print('- %s' % source.url)

    # create loopkup
    sources_loader = SourcesListLoader(sources)
    lookup = RosdepLookup.create_from_rospkg(sources_loader=sources_loader)

    # check if duplicates
    print("checking duplicates")
    db_name_view = {}
    has_duplicates = False
    view = lookup.get_rosdep_view(DEFAULT_VIEW_KEY, verbose=None)  # to call init
    for view_key in lookup.rosdep_db.get_view_dependencies(DEFAULT_VIEW_KEY):
        db_entry = lookup.rosdep_db.get_view_data(view_key)
        print('* %s' % view_key)
        for dep_name, dep_data in db_entry.rosdep_data.items():
            # skip unknown os names
            if os_name not in dep_data.keys():
                continue
            # skip unknown os codenames
            if (
                isinstance(dep_data[os_name], dict) and
                os_codename not in dep_data[os_name].keys()
            ):
                continue
            if dep_name in db_name_view:
                print('%s is multiply defined in\n\t%s and \n\t%s\n' %
                      (dep_name, db_name_view[dep_name], view_key))
                has_duplicates = True
            db_name_view[dep_name] = view_key
    return not has_duplicates
コード例 #3
0
ファイル: dependencies.py プロジェクト: javierdiazp/myros
    def __init__(self,
                 indexer,
                 ros_distro=None,
                 os_name=None,
                 os_codename=None):
        self.indexer = indexer

        if not os_name:
            os_detector = rospkg.os_detect.OsDetect()
            self.os_name = os_detector.get_name()
            self.os_codename = os_detector.get_codename()

        # FIXME: there should be a way to set this without using an environment variable
        if ros_distro:
            os.environ['ROS_DISTRO'] = ros_distro

        self.sources_loader = SourcesListLoader.create_default(verbose=False)
        self.lookup = RosdepLookup.create_from_rospkg(
            sources_loader=self.sources_loader)
        self.installer_context = create_default_installer_context(
            verbose=False)
        self.installer_keys = self.installer_context.get_os_installer_keys(
            self.os_name)

        self.default_key = self.installer_context.get_default_os_installer_key(
            self.os_name)
        self.installer = self.installer_context.get_installer(self.default_key)

        self.view = self.lookup.get_rosdep_view(DEFAULT_VIEW_KEY,
                                                verbose=False)
コード例 #4
0
ファイル: ros.py プロジェクト: iory/catkin_lint
def get_rosdep(quiet): # pragma: no cover
    from rosdep2.lookup import RosdepLookup
    from rosdep2.rospkg_loader import DEFAULT_VIEW_KEY
    from rosdep2.sources_list import SourcesListLoader
    sources_loader = SourcesListLoader.create_default()
    lookup = RosdepLookup.create_from_rospkg(sources_loader=sources_loader)
    return Rosdep(view=lookup.get_rosdep_view(DEFAULT_VIEW_KEY), quiet=quiet)
コード例 #5
0
def get_rosdep(quiet):
    from rosdep2.lookup import RosdepLookup
    from rosdep2.rospkg_loader import DEFAULT_VIEW_KEY
    from rosdep2.sources_list import SourcesListLoader
    sources_loader = SourcesListLoader.create_default()
    lookup = RosdepLookup.create_from_rospkg(sources_loader=sources_loader)
    return Rosdep(view=lookup.get_rosdep_view(DEFAULT_VIEW_KEY), quiet=quiet)
コード例 #6
0
ファイル: ros.py プロジェクト: fkie/catkin_lint
def get_rosdep(quiet):
    from rosdep2.lookup import RosdepLookup
    from rosdep2.rospkg_loader import DEFAULT_VIEW_KEY
    from rosdep2.sources_list import SourcesListLoader
    dummy = DummyRospkg()
    sources_loader = SourcesListLoader.create_default()
    lookup = RosdepLookup.create_from_rospkg(rospack=dummy, rosstack=dummy, sources_loader=sources_loader)
    return Rosdep(view=lookup.get_rosdep_view(DEFAULT_VIEW_KEY), quiet=quiet)
コード例 #7
0
    def __init__(self):  # noqa: D107
        installer_context = create_default_installer_context(verbose=False)
        self.installer, self.installer_keys, self.default_key, \
            self.os_name, self.os_version = get_default_installer(
                installer_context=installer_context, verbose=False)

        sources_loader = SourcesListLoader.create_default()
        lookup = RosdepLookup.create_from_rospkg(sources_loader=sources_loader)
        lookup.verbose = True

        self.view = lookup.get_rosdep_view(DEFAULT_VIEW_KEY, verbose=False)
コード例 #8
0
    def testRosdepKey(self):
        ret = True
        sources_loader = SourcesListLoader.create_default(sources_cache_dir=get_sources_cache_dir())
        lookup = RosdepLookup.create_from_rospkg(sources_loader=sources_loader)
        view = lookup.get_rosdep_view(DEFAULT_VIEW_KEY, verbose=None) # to call init

        db_name_view = dict()
        for view_key in lookup.rosdep_db.get_view_dependencies(DEFAULT_VIEW_KEY):
            db_entry=lookup.rosdep_db.get_view_data(view_key)       
            for dep_name, dep_data in db_entry.rosdep_data.items():
                if dep_name in db_name_view:
                    print("%s is multiply defined in\n\t%s and \n\t%s\n"%(dep_name, db_name_view[dep_name], view_key))
                    ret = False
                db_name_view[dep_name] = view_key

        self.assertTrue(ret)
コード例 #9
0
ファイル: linter.py プロジェクト: aleeper-forks/catkin_lint
 def __init__(self, rosdep_view=None):
     self.manifests = {}
     self.known_catkin_pkgs = set([])
     self.known_other_pkgs = set([])
     if rosdep_view is None:
         try:
             from rosdep2.lookup import RosdepLookup
             from rosdep2.rospkg_loader import DEFAULT_VIEW_KEY
             from rosdep2.sources_list import SourcesListLoader
             sources_loader = SourcesListLoader.create_default()
             lookup = RosdepLookup.create_from_rospkg(sources_loader=sources_loader)
             self.rosdep_view = lookup.get_rosdep_view(DEFAULT_VIEW_KEY)
         except Exception as err:
             sys.stderr.write("catkin_lint: cannot load rosdep database: %s\n" % str(err))
             sys.stderr.write("catkin_lint: unknown dependencies will be ignored\n")
             self.rosdep_view = {}
     else:
         self.rosdep_view = rosdep_view
     self.cache = {}
コード例 #10
0
    def __init__(self, indexer, ros_distro=None, os_name=None, os_codename=None):
        self.indexer = indexer

        if not os_name:
            os_detector = rospkg.os_detect.OsDetect()
            self.os_name = os_detector.get_name()
            self.os_codename = os_detector.get_codename()

        # FIXME: there should be a way to set this without using an environment variable
        if ros_distro:
            os.environ['ROS_DISTRO'] = ros_distro

        self.sources_loader = SourcesListLoader.create_default(verbose=False)
        self.lookup = RosdepLookup.create_from_rospkg(sources_loader=self.sources_loader)
        self.installer_context = create_default_installer_context(verbose=False)
        self.installer_keys = self.installer_context.get_os_installer_keys(self.os_name)

        self.default_key = self.installer_context.get_default_os_installer_key(self.os_name)
        self.installer = self.installer_context.get_installer(self.default_key)

        self.view = self.lookup.get_rosdep_view(DEFAULT_VIEW_KEY, verbose=False)
コード例 #11
0
def create_test_SourcesListLoader():
    from rosdep2.sources_list import SourcesListLoader
    return SourcesListLoader.create_default(sources_cache_dir=get_cache_dir(),
                                            verbose=True)
コード例 #12
0
ファイル: test_rosdep_lookup.py プロジェクト: fmanco/rosdep
def create_test_SourcesListLoader():
    from rosdep2.sources_list import SourcesListLoader
    return SourcesListLoader.create_default(sources_cache_dir=get_cache_dir(), verbose=True)
コード例 #13
0
def test_SourcesListLoader_create_default():
    from rosdep2.sources_list import update_sources_list, SourcesListLoader, DataSourceMatcher
    # create temp dir for holding sources cache
    tempdir = tempfile.mkdtemp()

    # pull in cache data
    sources_list_dir = get_test_dir()
    retval = update_sources_list(sources_list_dir=sources_list_dir,
                                 sources_cache_dir=tempdir,
                                 error_handler=None)
    assert retval

    # now test with cached data
    matcher = rosdep2.sources_list.DataSourceMatcher(['ubuntu', 'lucid'])
    loader = SourcesListLoader.create_default(matcher,
                                              sources_cache_dir=tempdir)
    assert loader.sources
    sources0 = loader.sources
    assert not any([s for s in loader.sources if not matcher.matches(s)])

    loader = SourcesListLoader.create_default(matcher,
                                              sources_cache_dir=tempdir)
    assert sources0 == loader.sources

    # now test with different matcher
    matcher2 = rosdep2.sources_list.DataSourceMatcher(['python'])
    loader2 = SourcesListLoader.create_default(matcher2,
                                               sources_cache_dir=tempdir)
    assert loader2.sources
    # - should have filtered down to python-only
    assert sources0 != loader2.sources
    assert not any([s for s in loader2.sources if not matcher2.matches(s)])

    # test API

    # very simple, always raises RNF
    try:
        loader.get_rosdeps('foo')
    except rospkg.ResourceNotFound:
        pass
    try:
        loader.get_view_key('foo')
    except rospkg.ResourceNotFound:
        pass

    assert [] == loader.get_loadable_resources()
    all_sources = [x.url for x in loader.sources]
    assert all_sources == loader.get_loadable_views()

    # test get_source early to make sure model matches expected
    try:
        loader.get_source('foo')
        assert False, "should have raised"
    except rospkg.ResourceNotFound:
        pass
    s = loader.get_source(GITHUB_URL)
    assert s.url == GITHUB_URL

    # get_view_dependencies
    # - loader doesn't new view name, so assume everything
    assert all_sources == loader.get_view_dependencies('foo')
    # - actual views don't depend on anything
    assert [] == loader.get_view_dependencies(GITHUB_URL)

    # load_view
    from rosdep2.model import RosdepDatabase
    for verbose in [True, False]:
        rosdep_db = RosdepDatabase()
        loader.load_view(GITHUB_URL, rosdep_db, verbose=verbose)
        assert rosdep_db.is_loaded(GITHUB_URL)
        assert [] == rosdep_db.get_view_dependencies(GITHUB_URL)
        entry = rosdep_db.get_view_data(GITHUB_URL)
        assert 'cmake' in entry.rosdep_data
        assert GITHUB_URL == entry.origin

    #  - coverage, repeat loader, should noop
    loader.load_view(GITHUB_URL, rosdep_db)
コード例 #14
0
def test_SourcesListLoader_create_default():
    from rosdep2.sources_list import update_sources_list, SourcesListLoader, DataSourceMatcher
    # create temp dir for holding sources cache
    tempdir = tempfile.mkdtemp()

    # pull in cache data
    sources_list_dir=get_test_dir()
    retval = update_sources_list(sources_list_dir=sources_list_dir,
                                 sources_cache_dir=tempdir, error_handler=None)
    assert retval
    
    # now test with cached data
    matcher = rosdep2.sources_list.DataSourceMatcher(['ubuntu', 'lucid'])
    loader = SourcesListLoader.create_default(matcher, sources_cache_dir=tempdir)
    assert loader.sources
    sources0 = loader.sources
    assert not any([s for s in loader.sources if not matcher.matches(s)])
    
    loader = SourcesListLoader.create_default(matcher, sources_cache_dir=tempdir)
    assert sources0 == loader.sources
    
    # now test with different matcher
    matcher2 = rosdep2.sources_list.DataSourceMatcher(['python'])
    loader2 = SourcesListLoader.create_default(matcher2, sources_cache_dir=tempdir)
    assert loader2.sources
    # - should have filtered down to python-only
    assert sources0 != loader2.sources
    assert not any([s for s in loader2.sources if not matcher2.matches(s)])

    # test API

    # very simple, always raises RNF
    try:
        loader.get_rosdeps('foo')
    except rospkg.ResourceNotFound: pass
    try:
        loader.get_view_key('foo')
    except rospkg.ResourceNotFound: pass

    assert [] == loader.get_loadable_resources()
    all_sources = [x.url for x in loader.sources]
    assert all_sources == loader.get_loadable_views()
    
    # test get_source early to make sure model matches expected
    try:
        loader.get_source('foo')
        assert False, "should have raised"
    except rospkg.ResourceNotFound: pass
    s = loader.get_source(GITHUB_URL)
    assert s.url == GITHUB_URL

    # get_view_dependencies
    # - loader doesn't new view name, so assume everything
    assert all_sources == loader.get_view_dependencies('foo')
    # - actual views don't depend on anything
    assert [] == loader.get_view_dependencies(GITHUB_URL)    

    # load_view
    from rosdep2.model import RosdepDatabase
    for verbose in [True, False]:
        rosdep_db = RosdepDatabase()
        loader.load_view(GITHUB_URL, rosdep_db, verbose=verbose)
        assert rosdep_db.is_loaded(GITHUB_URL)
        assert [] == rosdep_db.get_view_dependencies(GITHUB_URL)
        entry = rosdep_db.get_view_data(GITHUB_URL)
        assert 'cmake' in entry.rosdep_data
        assert GITHUB_URL == entry.origin

    #  - coverage, repeat loader, should noop
    loader.load_view(GITHUB_URL, rosdep_db)