本文整理匯總了Python中rosdep2.lookup.RosdepLookup類的典型用法代碼示例。如果您正苦於以下問題:Python RosdepLookup類的具體用法?Python RosdepLookup怎麽用?Python RosdepLookup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RosdepLookup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_RosdepLookup_create_from_rospkg
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
示例2: check_duplicates
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: get_rosdep
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)
示例4: test_RosdepInstaller_install_resolved
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))
示例5: test_RosdepLookup_resolve
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
示例6: test_RosdepLookup_get_rosdep_view_for_resource
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
示例7: test_RosdepLookup_get_rosdeps
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'))
示例8: get_rosdep
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)
示例9: test_RosdepInstaller_get_uninstalled_unconfigured
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
示例10: test_RosdepInstaller_ctor
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
示例11: test_RosdepLookup_get_resources_that_need
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']
示例12: test_RosdepInstaller_get_uninstalled
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
示例13: test_RosdepLookup_get_errors
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)
示例14: testRosdepKey
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)
示例15: test_RosdepLookup_resolve_all_errors
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