當前位置: 首頁>>代碼示例>>Python>>正文


Python RosdepLookup.create_from_rospkg方法代碼示例

本文整理匯總了Python中rosdep2.lookup.RosdepLookup.create_from_rospkg方法的典型用法代碼示例。如果您正苦於以下問題:Python RosdepLookup.create_from_rospkg方法的具體用法?Python RosdepLookup.create_from_rospkg怎麽用?Python RosdepLookup.create_from_rospkg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rosdep2.lookup.RosdepLookup的用法示例。


在下文中一共展示了RosdepLookup.create_from_rospkg方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_RosdepLookup_create_from_rospkg

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepLookup_create_from_rospkg():
    from rosdep2.lookup import RosdepLookup
    rospack, rosstack = get_test_rospkgs()

    # these are just tripwire, can't actually test as it depends on external env
    lookup = RosdepLookup.create_from_rospkg()
    
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack)
    assert rospack == lookup.loader._rospack
    
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack)
    assert rospack == lookup.loader._rospack
    assert rosstack == lookup.loader._rosstack
開發者ID:fmanco,項目名稱:rosdep,代碼行數:15,代碼來源:test_rosdep_lookup.py

示例2: check_duplicates

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
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
開發者ID:ipa-fxm,項目名稱:rosdistro,代碼行數:36,代碼來源:check_duplicates.py

示例3: get_rosdep

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
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)
開發者ID:iory,項目名稱:catkin_lint,代碼行數:9,代碼來源:ros.py

示例4: test_RosdepInstaller_install_resolved

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepInstaller_install_resolved():
    from rosdep2 import create_default_installer_context
    from rosdep2.lookup import RosdepLookup
    from rosdep2.installers import RosdepInstaller
    from rosdep2.platforms.debian import APT_INSTALLER
    
    from rosdep2.lookup import RosdepLookup
    rospack, rosstack = get_test_rospkgs()
    
    # create our test fixture.  use most of the default toolchain, but
    # replace the apt installer with one that we can have more fun
    # with.  we will do all tests with ubuntu lucid keys -- other
    # tests should cover different resolution cases.
    sources_loader = create_test_SourcesListLoader()
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack, sources_loader=sources_loader)
    context = create_default_installer_context()
    context.set_os_override('ubuntu', 'lucid')
    installer = RosdepInstaller(context, lookup)
    
    with fakeout() as (stdout, stderr):
        installer.install_resolved(APT_INSTALLER, [], simulate=True, verbose=False)
    with fakeout() as (stdout, stderr):
        installer.install_resolved(APT_INSTALLER, [], simulate=True, verbose=True)
    assert stdout.getvalue().strip() == '#No packages to install'
    with fakeout() as (stdout, stderr):            
        installer.install_resolved(APT_INSTALLER, ['rosdep-fake1', 'rosdep-fake2'], simulate=True, verbose=True)
    stdout_lines = [x.strip() for x in stdout.getvalue().split('\n') if x.strip()]
    assert stdout_lines == ['#[apt] Installation commands:',
                            'sudo apt-get install rosdep-fake1',
                            'sudo apt-get install rosdep-fake2',
                            ], ("%s: %s"%(stdout.getvalue(), stdout_lines))
開發者ID:jmesmon,項目名稱:rosdep,代碼行數:33,代碼來源:test_rosdep_installers.py

示例5: test_RosdepLookup_resolve

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepLookup_resolve():
    from rosdep2 import create_default_installer_context
    from rosdep2.lookup import RosdepLookup
    rospack, rosstack = get_test_rospkgs()
    
    sources_loader = create_test_SourcesListLoader()
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack,
                                             sources_loader=sources_loader)
    installer_context = create_default_installer_context()
    installer_context.set_os_override('ubuntu', 'lucid')

    # repeat for caching
    for count in xrange(0, 2):
        installer_key, resolution, dependencies = lookup.resolve('testtinyxml', 'rospack_fake', installer_context)
        assert 'apt' == installer_key
        assert ['libtinyxml-dev'] == resolution
        assert [] == dependencies

        installer_key, resolution, dependencies = lookup.resolve('testboost', 'roscpp_fake', installer_context)
        assert 'apt' == installer_key
        assert ['libboost1.40-all-dev'] == resolution
        assert [] == dependencies

        installer_key, resolution, dependencies = lookup.resolve('testlibtool', 'roscpp_fake', installer_context)
        assert 'apt' == installer_key
        assert set(['libtool', 'libltdl-dev']) == set(resolution)
        assert [] == dependencies
開發者ID:fmanco,項目名稱:rosdep,代碼行數:29,代碼來源:test_rosdep_lookup.py

示例6: test_RosdepLookup_get_rosdep_view_for_resource

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepLookup_get_rosdep_view_for_resource():
    from rosdep2.lookup import RosdepLookup
    from rosdep2.rospkg_loader import DEFAULT_VIEW_KEY, RosPkgLoader
    rospack, rosstack = get_test_rospkgs()
    
    sources_loader = create_test_SourcesListLoader()
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack,
                                             sources_loader=sources_loader)
    # assumption of our tests
    assert isinstance(lookup.loader, RosPkgLoader)

    # depends on nothing
    cache_raw = get_cache_raw()
    py_cache_raw = get_cache_raw_python()
    # - first pass: no cache
    ros_view = lookup.get_rosdep_view_for_resource('roscpp_fake')
    libtool = ros_view.lookup('testlibtool')
    assert BASE_URL == libtool.origin
    assert cache_raw['testlibtool'] == libtool.data
    python = ros_view.lookup('testpython')
    assert PYTHON_URL == python.origin
    assert py_cache_raw['testpython'] == python.data

    # package not in stack, should return 
    assert lookup.get_rosdep_view_for_resource('just_a_package').name is DEFAULT_VIEW_KEY
開發者ID:fmanco,項目名稱:rosdep,代碼行數:27,代碼來源:test_rosdep_lookup.py

示例7: test_RosdepLookup_get_rosdeps

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepLookup_get_rosdeps():
    from rosdep2.loader import RosdepLoader
    from rosdep2.lookup import RosdepLookup
    rospack, rosstack = get_test_rospkgs()
    
    sources_loader = create_test_SourcesListLoader()
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rospack,
                                             sources_loader=sources_loader)
    assert lookup.get_loader() is not None
    assert isinstance(lookup.get_loader(), RosdepLoader)
    print(lookup.get_rosdeps('empty_package'))
    assert lookup.get_rosdeps('empty_package') == []

    try:
        assert lookup.get_rosdeps('not a resource') == []
        assert False, "should have raised"
    except ResourceNotFound:
        pass
    
    print(lookup.get_rosdeps('stack1_p1'))
    assert set(lookup.get_rosdeps('stack1_p1')) == set(['stack1_dep1', 'stack1_p1_dep1', 'stack1_p1_dep2'])
    assert set(lookup.get_rosdeps('stack1_p1', implicit=False)) == set(['stack1_dep1', 'stack1_p1_dep1', 'stack1_p1_dep2'])
    
    print(lookup.get_rosdeps('stack1_p2'))
    assert set(lookup.get_rosdeps('stack1_p2', implicit=False)) == set(['stack1_dep1', 'stack1_dep2', 'stack1_p2_dep1']), set(lookup.get_rosdeps('stack1_p2'))
    assert set(lookup.get_rosdeps('stack1_p2', implicit=True)) == set(['stack1_dep1', 'stack1_dep2', 'stack1_p1_dep1', 'stack1_p1_dep2', 'stack1_p2_dep1']), set(lookup.get_rosdeps('stack1_p2'))    
開發者ID:fmanco,項目名稱:rosdep,代碼行數:28,代碼來源:test_rosdep_lookup.py

示例8: get_rosdep

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
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)
開發者ID:fkie,項目名稱:catkin_lint,代碼行數:10,代碼來源:ros.py

示例9: test_RosdepInstaller_get_uninstalled_unconfigured

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepInstaller_get_uninstalled_unconfigured():
    from rosdep2 import create_default_installer_context, RosdepInternalError
    from rosdep2.lookup import RosdepLookup, ResolutionError
    from rosdep2.installers import RosdepInstaller, PackageManagerInstaller
    from rosdep2.platforms.debian import APT_INSTALLER
    
    from rosdep2.lookup import RosdepLookup
    rospack, rosstack = get_test_rospkgs()
    
    sources_loader = create_test_SourcesListLoader()
    # create our test fixture.  we want to setup a fixture that cannot resolve the rosdep data in order to test error conditions
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack, sources_loader=sources_loader)
    context = create_default_installer_context()
    context.set_os_override('ubuntu', 'lucid')
    installer = RosdepInstaller(context, lookup)
    # - delete the apt installer
    context.set_installer(APT_INSTALLER, None)

    for verbose in [True, False]:
        uninstalled, errors = installer.get_uninstalled(['empty'], verbose)
        assert not uninstalled, uninstalled
        assert not errors

        # make sure there is an error when we lookup something that resolves to an apt depend
        uninstalled, errors = installer.get_uninstalled(['roscpp_fake'], verbose)
        assert not uninstalled, uninstalled
        assert errors.keys() == ['roscpp_fake']

        uninstalled, errors = installer.get_uninstalled(['roscpp_fake', 'stack1_p1'], verbose)
        assert not uninstalled, uninstalled
        assert set(errors.keys()) == set(['roscpp_fake', 'stack1_p1'])
        print(errors)
        assert isinstance(errors['roscpp_fake'], ResolutionError), errors['roscpp_fake'][0]

    # fake/bad installer to test that we re-cast general installer issues
    class BadInstaller(PackageManagerInstaller):
        def __init__(self):
            super(BadInstaller, self).__init__(lambda x: x)
        def get_packages_to_install(*args):
            raise Exception("deadbeef")
    context.set_installer(APT_INSTALLER, BadInstaller())
    try:
        installer.get_uninstalled(['roscpp_fake'])
        assert False, "should have raised"
    except RosdepInternalError as e:
        assert 'apt' in str(e)
    
    # annoying mock to test generally impossible error condition
    from mock import Mock
    lookup = Mock(spec=RosdepLookup)
    lookup.resolve_all.return_value = ([('bad-key', ['stuff'])], [])
    
    installer = RosdepInstaller(context, lookup)
    try:
        installer.get_uninstalled(['roscpp_fake'])
        assert False, "should have raised"
    except RosdepInternalError:
        pass
開發者ID:AurelienBallier,項目名稱:rosdep,代碼行數:60,代碼來源:test_rosdep_installers.py

示例10: test_RosdepInstaller_ctor

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepInstaller_ctor():
    # tripwire/coverage
    from rosdep2 import create_default_installer_context
    from rosdep2.lookup import RosdepLookup
    from rosdep2.installers import RosdepInstaller
    lookup = RosdepLookup.create_from_rospkg()
    context = create_default_installer_context()
    installer = RosdepInstaller(context, lookup)
    assert lookup == installer.lookup
    assert context == installer.installer_context    
開發者ID:AurelienBallier,項目名稱:rosdep,代碼行數:12,代碼來源:test_rosdep_installers.py

示例11: test_RosdepLookup_get_resources_that_need

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepLookup_get_resources_that_need():
    from rosdep2.lookup import RosdepLookup
    rospack, rosstack = get_test_rospkgs()
    
    sources_loader = create_test_SourcesListLoader()
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rospack,
                                             sources_loader=sources_loader)

    assert lookup.get_resources_that_need('fake') ==  []
    assert set(lookup.get_resources_that_need('stack1_dep1')) ==  set(['stack1_p1', 'stack1_p2'])
    assert lookup.get_resources_that_need('stack1_dep2') ==  ['stack1_p2']
    assert lookup.get_resources_that_need('stack1_p1_dep1') ==  ['stack1_p1']
開發者ID:fmanco,項目名稱:rosdep,代碼行數:14,代碼來源:test_rosdep_lookup.py

示例12: test_RosdepInstaller_get_uninstalled

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepInstaller_get_uninstalled():
    from rosdep2 import create_default_installer_context
    from rosdep2.lookup import RosdepLookup
    from rosdep2.installers import RosdepInstaller
    from rosdep2.platforms.debian import APT_INSTALLER
    
    from rosdep2.lookup import RosdepLookup
    rospack, rosstack = get_test_rospkgs()
    
    # create our test fixture.  use most of the default toolchain, but
    # replace the apt installer with one that we can have more fun
    # with.  we will do all tests with ubuntu lucid keys -- other
    # tests should cover different resolution cases.
    sources_loader = create_test_SourcesListLoader()
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack, sources_loader=sources_loader)
    context = create_default_installer_context()
    context.set_os_override('ubuntu', 'lucid')
    installer = RosdepInstaller(context, lookup)
    
    # in this first test, detect_fn detects everything as installed
    fake_apt = get_fake_apt(lambda x: x)
    context.set_installer(APT_INSTALLER, fake_apt)

    for verbose in [True, False]:
        tests = [['roscpp_fake'], ['roscpp_fake', 'rospack_fake'], ['empty_package'],
                 ['roscpp_fake', 'rospack_fake', 'empty_package'],
                 ['roscpp_fake', 'rospack_fake'],
                 ]
        for test in tests:
            uninstalled, errors = installer.get_uninstalled(test, verbose)
            assert not uninstalled, uninstalled
            assert not errors, errors

    # in this second test, detect_fn detects nothing as installed
    fake_apt = get_fake_apt(lambda x: [])
    context.set_installer(APT_INSTALLER, fake_apt)

    for verbose in [True, False]:
        uninstalled, errors = installer.get_uninstalled(['empty'], verbose)
        assert not uninstalled, uninstalled
        assert not errors

        expected = set(['libltdl-dev', 'libboost1.40-all-dev', 'libtool'])
        uninstalled, errors = installer.get_uninstalled(['roscpp_fake'], verbose)
        assert uninstalled.keys() == [APT_INSTALLER]
        assert set(uninstalled[APT_INSTALLER]) == expected
        assert not errors

        expected = ['libtinyxml-dev']
        uninstalled, errors = installer.get_uninstalled(['rospack_fake'], verbose)
        assert uninstalled.keys() == [APT_INSTALLER]
        assert uninstalled[APT_INSTALLER] == expected, uninstalled
        assert not errors
開發者ID:tfoote,項目名稱:rosdep,代碼行數:55,代碼來源:test_rosdep_installers.py

示例13: test_RosdepLookup_get_errors

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepLookup_get_errors():
    from rosdep2.lookup import RosdepLookup
    rospack, rosstack = get_test_rospkgs()
    tree_dir = get_test_tree_dir()
    sources_loader = create_test_SourcesListLoader()
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack,
                                             sources_loader=sources_loader)

    # shouldn't be any errors (yet)
    assert lookup.get_errors() == []

    # force errors
    lookup._load_all_views(lookup.loader)
開發者ID:fmanco,項目名稱:rosdep,代碼行數:15,代碼來源:test_rosdep_lookup.py

示例14: testRosdepKey

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
    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)
開發者ID:k-okada,項目名稱:rosdep,代碼行數:18,代碼來源:test_rosdep_duplicates_key.py

示例15: test_RosdepLookup_resolve_all_errors

# 需要導入模塊: from rosdep2.lookup import RosdepLookup [as 別名]
# 或者: from rosdep2.lookup.RosdepLookup import create_from_rospkg [as 別名]
def test_RosdepLookup_resolve_all_errors():
    from rosdep2.installers import InstallerContext
    from rosdep2.lookup import RosdepLookup, ResolutionError
    rospack, rosstack = get_test_rospkgs()
    sources_loader = create_test_SourcesListLoader()
    lookup = RosdepLookup.create_from_rospkg(rospack=rospack, rosstack=rosstack,
                                             sources_loader=sources_loader)
    # the installer context has nothing in it, lookups will fail
    installer_context = InstallerContext()
    installer_context.set_os_override('ubuntu', 'lucid')

    resolutions, errors = lookup.resolve_all(['rospack_fake'], installer_context)
    assert 'rospack_fake' in errors

    resolutions, errors = lookup.resolve_all(['not_a_resource'], installer_context)
    assert 'not_a_resource' in errors, errors
開發者ID:fmanco,項目名稱:rosdep,代碼行數:18,代碼來源:test_rosdep_lookup.py


注:本文中的rosdep2.lookup.RosdepLookup.create_from_rospkg方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。