How to use the rospkg.os_detect function in rospkg

To help you get started, we’ve selected a few rospkg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ros-infrastructure / rosdep / test / test_rosdep_main.py View on Github external
def test_check(self):
        sources_cache = get_cache_dir()
        cmd_extras = ['-c', sources_cache]

        with fakeout() as b:
            try:
                rosdep_main(['check', 'python_dep'] + cmd_extras)
            except SystemExit:
                assert False, 'system exit occurred: %s\n%s' % (b[0].getvalue(), b[1].getvalue())

            stdout, stderr = b
            assert stdout.getvalue().strip() == 'All system dependencies have been satisfied', stdout.getvalue()
            assert not stderr.getvalue(), stderr.getvalue()
        try:
            osd = rospkg.os_detect.OsDetect()
            override = '%s:%s' % (osd.get_name(), osd.get_codename())
            with fakeout() as b:
                rosdep_main(['check', 'python_dep', '--os', override] + cmd_extras)
                stdout, stderr = b
                assert stdout.getvalue().strip() == 'All system dependencies have been satisfied'
                assert not stderr.getvalue(), stderr.getvalue()
        except SystemExit:
            assert False, 'system exit occurred'

        # this used to abort, but now rosdep assumes validity for even empty stack args
        try:
            with fakeout() as b:
                rosdep_main(['check', 'packageless'] + cmd_extras)
                stdout, stderr = b
                assert stdout.getvalue().strip() == 'All system dependencies have been satisfied'
                assert not stderr.getvalue(), stderr.getvalue()
github ros-infrastructure / rosdep / test / test_rosdep_sources_list.py View on Github external
def test_DataSourceMatcher_create_default():
    distro_name = rospkg.distro.current_distro_codename()
    os_detect = rospkg.os_detect.OsDetect()
    os_name, os_version, os_codename = os_detect.detect_os()

    matcher = rosdep2.sources_list.DataSourceMatcher.create_default()

    # matches full
    os_data_source = rosdep2.sources_list.DataSource('yaml', 'http://fake/url', [distro_name, os_name, os_codename])
    assert matcher.matches(os_data_source)

    # matches against current os
    os_data_source = rosdep2.sources_list.DataSource('yaml', 'http://fake/url', [os_name, os_codename])
    assert matcher.matches(os_data_source)

    # matches against current distro
    distro_data_source = rosdep2.sources_list.DataSource('yaml', 'http://fake/url', [distro_name])
    assert matcher.matches(distro_data_source)
github ros-infrastructure / rosdep / test / test_rosdep_gentoo.py View on Github external
def is_gentoo():
    return rospkg.os_detect.Gentoo().is_os()
github ros-infrastructure / rosdep / test / test_rosdep_slackware.py View on Github external
def is_slackware():
    return rospkg.os_detect.Slackware().is_os()
github ros / ros_comm / utilities / roswtf / src / roswtf / py_pip_deb_checks.py View on Github external
def get_host_os():
    """Determines the name of the host operating system"""
    import rospkg.os_detect
    os_detector = rospkg.os_detect.OsDetect()
    return (os_detector.detect_os())[0]
github ros-infrastructure / rosdep / src / rosdep2 / sources_list.py View on Github external
def create_default(os_override=None):
        """
        Create a :class:`DataSourceMatcher` to match the current
        configuration.

        :param os_override: (os_name, os_codename) tuple to override
            OS detection
        :returns: :class:`DataSourceMatcher`
        """
        distro_name = rospkg.distro.current_distro_codename()
        if os_override is None:
            os_detect = rospkg.os_detect.OsDetect()
            os_name, os_version, os_codename = os_detect.detect_os()
        else:
            os_name, os_codename = os_override
        tags = [t for t in (distro_name, os_name, os_codename) if t]
        return DataSourceMatcher(tags)
github ros / ros / tools / rosmake / src / rosmake / package_stats.py View on Github external
def __init__(self, dependency_tracker, os_name=None, os_version=None):
        if not os_name and not os_version:
            try:
                osd = rospkg.os_detect.OsDetect()
                self.os_name = osd.get_codename()
                self.os_version = osd.get_version()
            except rospkg.os_detect.OsNotDetected:
                sys.stderr.write('Could not detect OS. platform detection will not work\n')
        else:
            self.os_name = os_name
            self.os_version = os_version

        self.rospack = rospkg.RosPack()
        self.blacklisted = {}
        self.blacklisted_osx = {}
        self.nobuild = set()
        self.nomakefile = set()
        self.packages_tested = set()
        self.dependency_tracker = dependency_tracker
        self.build_failed = set()
github ros / ros / tools / rosmake / src / rosmake / package_stats.py View on Github external
def __init__(self, dependency_tracker, os_name=None, os_version=None):
        if not os_name and not os_version:
            try:
                osd = rospkg.os_detect.OsDetect()
                self.os_name = osd.get_codename()
                self.os_version = osd.get_version()
            except rospkg.os_detect.OsNotDetected:
                sys.stderr.write('Could not detect OS. platform detection will not work\n')
        else:
            self.os_name = os_name
            self.os_version = os_version

        self.rospack = rospkg.RosPack()
        self.blacklisted = {}
        self.blacklisted_osx = {}
        self.nobuild = set()
        self.nomakefile = set()
        self.packages_tested = set()
        self.dependency_tracker = dependency_tracker
        self.build_failed = set()