Exemplo n.º 1
0
def readPackageCMakeData(rosDebYamlFileName):
    """
    Read the cmake meta data for packages from a cmake yaml file:
    package1:
        xenial/trusty:
            name: ...
            include_dirs: []
            library_dirs: []
            libraries: []
            components: []
    """
    # load ros dep yaml file
    f = open(rosDebYamlFileName, "r")
    rosDebYamlData = yaml.load(f, Loader=Loader)

    # dictionary for storing cmake dependencies
    # e.g. { "<package name 1>" -> PackageCMakeData, "<package name 2>" -> PackageCMakeData ... }
    data = {}
    distribution = OsDetect().detect_os()[2]

    for packageName, packageCMakeData in rosDebYamlData.items():
        # find out which distribution
        if "name" in packageCMakeData:
            data[packageName] = PackageCMakeData(packageCMakeData)
        elif distribution in packageCMakeData:
            data[packageName] = PackageCMakeData(
                packageCMakeData[distribution])
        elif not packageCMakeData:
            data[packageName] = PackageCMakeData()  # placeholder
    return data
Exemplo n.º 2
0
def test_OsDetect_single():
    # test each method twice with new instance b/c of caching
    from rospkg.os_detect import OsDetect
    detect = OsDetect([('TrueOs', TrueOs())])
    assert "TrueOs" == detect.get_name()
    assert "TrueOs" == detect.get_name()
    detect = OsDetect([('TrueOs', TrueOs())])
    assert "os_version" == detect.get_version()
    assert "os_version" == detect.get_version()
    detect = OsDetect([('TrueOs', TrueOs())])
    assert "os_codename" == detect.get_codename()
    assert "os_codename" == detect.get_codename()

    detect = OsDetect([('TrueOs', TrueOs())])
    assert isinstance(detect.get_detector(), TrueOs)
    assert isinstance(detect.get_detector('TrueOs'), TrueOs)
Exemplo n.º 3
0
    def __init__(self, stop_app_postexec_fn):
        '''
          @param stop_app_postexec_fn : callback to fire when a listener detects an app getting stopped.
          @type method with no args
        '''
        self._stop_app_postexec_fn = stop_app_postexec_fn
        self.app_list = {}
        self.rocon_master_info = {}
        self.is_connect = False
        self.is_app_running = False
        self.key = uuid.uuid4()

        self.app_pid = 0

        # this might be naive and only work well on ubuntu...
        os_codename = OsDetect().get_codename()
        # this would be great as a configurable parameter
        name = "rqt_remocon_" + self.key.hex
        self.rocon_uri = rocon_uri.parse(
                            "rocon:/pc/" + name + "/" + rocon_std_msgs.Strings.URI_WILDCARD + "/" + os_codename
                            )
        # be also great to have a configurable icon...with a default
        self.platform_info = rocon_std_msgs.PlatformInfo(version=rocon_std_msgs.Strings.ROCON_VERSION,
                                                       uri=str(self.rocon_uri),
                                                       icon=rocon_std_msgs.Icon()
                                                       )
        print("[remocon_info] info component initialised")
Exemplo n.º 4
0
def test_OsDetect():
    from rospkg.os_detect import OsDetect
    detect = OsDetect()
    try:
        detect.get_detector('fake')
        assert False, "should raise"
    except KeyError:
        pass
Exemplo n.º 5
0
def auto_detected_triplet():
    machine_name = platform.machine().lower()
    os_name = OsDetect().get_name().lower()
    if machine_name in ['amd64', 'x86_64']:
        return 'x64-%s' % os_name
    elif machine_name in ['i386', 'i686']:
        return 'x86-%s' % os_name
    else:
        raise RosdepInternalError
Exemplo n.º 6
0
def test_OsDetect_ROS_OVERRIDE():
    from rospkg.os_detect import OsDetect
    detect = OsDetect([('TrueOs', TrueOs())])
    env = {'ROS_OS_OVERRIDE': 'arch'}
    assert detect.detect_os(env=env) == ('arch', '', ''), \
        detect.detect_os(env=env)
    env = {'ROS_OS_OVERRIDE': 'fubuntu:04.10'}
    assert detect.detect_os(env=env) == ('fubuntu', '04.10', '')
    env = {'ROS_OS_OVERRIDE': 'fubuntu:04.10:opaque'}
    assert detect.detect_os(env=env) == ('fubuntu', '04.10', 'opaque')
Exemplo n.º 7
0
def test_OsDetect_register_default_add_detector():
    # test behavior of register_default and add_detector.  Both take
    # precedence over previous detectors, but at different scopes.
    from rospkg.os_detect import OsDetect
    o1 = TrueOs()
    o2 = TrueOs2()
    key = 'TrueOs'
    detect = OsDetect([(key, o1)])

    assert detect.get_detector(key) == o1
    detect.register_default(key, o2)
    assert detect.get_detector(key) == o1
    detect.add_detector(key, o2)
    assert detect.get_detector(key) == o2

    detect = OsDetect()
    assert detect.get_detector(key) == o2
    detect.add_detector(key, o1)
    assert detect.get_detector(key) == o1

    # restore precendence of o1 in default list
    detect.register_default(key, o1)
    detect = OsDetect()
    assert detect.get_detector(key) == o1
Exemplo n.º 8
0
def test_InstallerContext_ctor():
    from rosdep2.installers import InstallerContext
    from rospkg.os_detect import OsDetect

    context = InstallerContext()
    assert context.get_os_detect() is not None
    assert isinstance(context.get_os_detect(), OsDetect)

    detect = OsDetect()
    context = InstallerContext(detect)
    assert context.get_os_detect() == detect
    assert len(context.get_installer_keys()) == 0
    assert len(context.get_os_keys()) == 0

    context.verbose = True
    assert context.get_os_detect() == detect
    assert len(context.get_installer_keys()) == 0
    assert len(context.get_os_keys()) == 0
Exemplo n.º 9
0
def test_OsDetect_nomatch():
    from rospkg.os_detect import OsDetect, OsNotDetected
    detect = OsDetect([('Dummy', FalseOs())])
    assert isinstance(detect.get_detector('Dummy'), FalseOs)
    try:
        detect.get_name()
        assert False
    except OsNotDetected:
        pass
    try:
        detect.get_version()
        assert False
    except OsNotDetected:
        pass
    try:
        detect.get_detector()
        assert False
    except OsNotDetected:
        pass
Exemplo n.º 10
0
    def __init__(self, stop_interaction_postexec_fn):
        '''
          @param stop_app_postexec_fn : callback to fire when a listener detects an app getting stopped.
          @type method with no args
        '''
        self._interactions_table = InteractionsTable()
        self._stop_interaction_postexec_fn = stop_interaction_postexec_fn
        self.is_connect = False
        self.key = uuid.uuid4()
        self._ros_master_port = None
        try:
            self._roslaunch_terminal = rocon_launch.create_terminal()
        except (rocon_launch.UnsupportedTerminal,
                rocon_python_comms.NotFoundException) as e:
            console.warning(
                "Cannot find a suitable terminal, falling back to the current terminal [%s]"
                % str(e))
            self._roslaunch_terminal = rocon_launch.create_terminal(
                rocon_launch.terminals.active)

        # this might be naive and only work well on ubuntu...
        os_codename = OsDetect().get_codename()
        webbrowser_codename = utils.get_web_browser_codename()
        # this would be good as a persistant variable so the user can set something like 'Bob'
        self.name = "rqt_remocon_" + self.key.hex
        self.rocon_uri = rocon_uri.parse("rocon:/pc/" + self.name + "/" +
                                         rocon_std_msgs.Strings.URI_WILDCARD +
                                         "/" + os_codename + "|" +
                                         webbrowser_codename)
        # be also great to have a configurable icon...with a default
        self.platform_info = rocon_std_msgs.PlatformInfo(
            version=rocon_std_msgs.Strings.ROCON_VERSION,
            uri=str(self.rocon_uri),
            icon=rocon_std_msgs.Icon())
        console.logdebug("Interactive Client : initialised")
        self.pairing = None  # if an interaction is currently pairing, this will store its hash

        # expose underlying functionality higher up
        self.interactions = self._interactions_table.generate_role_view
        """Get a dictionary of interactions belonging to the specified role."""
Exemplo n.º 11
0
    def __init__(self, os_detect=None):
        """
        :param os_detect: (optional)
        :class:`rospkg.os_detect.OsDetect` instance to use for
          detecting platforms.  If `None`, default instance will be
          used.
        """
        # platform configuration
        self.installers = {}
        self.os_installers = {}
        self.default_os_installer = {}

        # stores configuration of which value to use for the OS version key (version number or codename)
        self.os_version_type = {}

        # OS detection and override
        if os_detect is None:
            os_detect = OsDetect()
        self.os_detect = os_detect
        self.os_override = None

        self.verbose = False
Exemplo n.º 12
0
def test_ubuntu():
    from rospkg.os_detect import OsDetect, OsNotDetected

    os_detector = OsDetect()
    detect = os_detector.get_detector('ubuntu')
    detect.lsb_info = ('Ubuntu', '10.04', 'lucid')

    assert detect.get_version() == '10.04', detect.get_version()
    assert detect.get_codename() == 'lucid', detect.get_codename()

    # test freely
    if not detect.is_os():
        try:
            detect.get_version()
            assert False
        except OsNotDetected:
            pass
        try:
            detect.get_codename()
            assert False
        except OsNotDetected:
            pass
Exemplo n.º 13
0
def test_InstallerContext_installers():
    from rosdep2.installers import InstallerContext, Installer
    from rospkg.os_detect import OsDetect
    detect = OsDetect()
    context = InstallerContext(detect)
    context.verbose = True

    key = 'fake-apt'
    try:
        installer = context.get_installer(key)
        assert False, "should have raised: %s" % (installer)
    except KeyError:
        pass

    class Foo:
        pass

    class FakeInstaller(Installer):
        pass

    class FakeInstaller2(Installer):
        pass

    # test TypeError on set_installer
    try:
        context.set_installer(key, 1)
        assert False, "should have raised"
    except TypeError:
        pass
    try:
        context.set_installer(key, Foo())
        assert False, "should have raised"
    except TypeError:
        pass
    try:
        # must be instantiated
        context.set_installer(key, FakeInstaller)
        assert False, "should have raised"
    except TypeError:
        pass

    installer = FakeInstaller()
    installer2 = FakeInstaller2()
    context.set_installer(key, installer)
    assert context.get_installer(key) == installer
    assert list(context.get_installer_keys()) == [key]

    # repeat with same args
    context.set_installer(key, installer)
    assert context.get_installer(key) == installer
    assert list(context.get_installer_keys()) == [key]

    # repeat with new installer
    context.set_installer(key, installer2)
    assert context.get_installer(key) == installer2
    assert list(context.get_installer_keys()) == [key]

    # repeat with new key
    key2 = 'fake-port'
    context.set_installer(key2, installer2)
    assert context.get_installer(key2) == installer2
    assert set(context.get_installer_keys()) == set([key, key2])

    # test installer deletion
    key3 = 'fake3'
    context.set_installer(key3, installer2)
    assert context.get_installer(key3) == installer2
    assert set(context.get_installer_keys()) == set([key, key2, key3])
    context.set_installer(key3, None)
    try:
        context.get_installer(key3)
        assert False
    except KeyError:
        pass
    assert set(context.get_installer_keys()) == set([key, key2])
Exemplo n.º 14
0
def test_tripwire_ubuntu():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('ubuntu')
Exemplo n.º 15
0
def test_tripwire_manjaro():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('manjaro')
Exemplo n.º 16
0
def test_tripwire_freebsd():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('freebsd')
Exemplo n.º 17
0
def test_tripwire_centos():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('centos')
Exemplo n.º 18
0
def test_tripwire_osx():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('osx')
Exemplo n.º 19
0
def test_tripwire_slackware():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('slackware')
Exemplo n.º 20
0
def test_tripwire_fedora():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('fedora')
Exemplo n.º 21
0
def test_tripwire_gentoo():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('gentoo')
Exemplo n.º 22
0
def test_tripwire_opensuse():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('opensuse')
Exemplo n.º 23
0
def test_InstallerContext_os_installers():
    from rosdep2.installers import InstallerContext, Installer
    from rospkg.os_detect import OsDetect
    detect = OsDetect()
    context = InstallerContext(detect)
    context.verbose = True

    os_key = 'ubuntu'
    try:
        context.get_os_installer_keys(os_key)
        assert False, "should have raised"
    except KeyError:
        pass
    try:
        context.get_default_os_installer_key(os_key)
        assert False, "should have raised"
    except KeyError:
        pass
    try:
        context.add_os_installer_key(os_key, 'fake-key')
        assert False, "should have raised"
    except KeyError:
        pass
    try:
        context.set_default_os_installer_key(os_key, 'non-method')
        assert False, "should have raised"
    except KeyError:
        pass
    try:
        context.set_default_os_installer_key(os_key, lambda self: 'fake-key')
        assert False, "should have raised"
    except KeyError:
        pass
    try:
        context.get_default_os_installer_key('bad-os')
        assert False, "should have raised"
    except KeyError:
        pass

    installer_key1 = 'fake1'
    installer_key2 = 'fake2'

    class FakeInstaller(Installer):
        pass

    class FakeInstaller2(Installer):
        pass

    # configure our context with two valid installers
    context.set_installer(installer_key1, FakeInstaller())
    context.set_installer(installer_key2, FakeInstaller2())

    # start adding installers for os_key
    context.add_os_installer_key(os_key, installer_key1)
    assert context.get_os_installer_keys(os_key) == [installer_key1]

    # retest set_default_os_installer_key, now with installer_key not configured on os
    try:
        context.set_default_os_installer_key(os_key,
                                             lambda self: installer_key2)
        assert False, "should have raised"
    except KeyError as e:
        assert 'add_os_installer' in str(e), e

    # now properly add in key2
    context.add_os_installer_key(os_key, installer_key2)
    assert set(context.get_os_installer_keys(os_key)) == set(
        [installer_key1, installer_key2])

    # test default
    assert None == context.get_default_os_installer_key(os_key)
    context.set_default_os_installer_key(os_key, lambda self: installer_key1)
    assert installer_key1 == context.get_default_os_installer_key(os_key)
    context.set_default_os_installer_key(os_key, lambda self: installer_key2)
    assert installer_key2 == context.get_default_os_installer_key(os_key)

    # retest set_default_os_installer_key, now with invalid os
    try:
        context.set_default_os_installer_key('bad-os',
                                             lambda self: installer_key1)
        assert False, "should have raised"
    except KeyError:
        pass
Exemplo n.º 24
0
def test_tripwire_debian():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('debian')
Exemplo n.º 25
0
def test_tripwire_rhel():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('rhel')
Exemplo n.º 26
0
def test_tripwire_arch():
    from rospkg.os_detect import OsDetect
    os_detect = OsDetect()
    os_detect.get_detector('arch')