Beispiel #1
0
    def check(self):
        """Check network configuration."""
        result = Result()
        # check ifcfg import for windows and osx users
        ifcfg_ifaces = ifcfg.interfaces()

        has_loopback, has_non_loopback, has_multicast = _check_network_config_helper(
            ifcfg_ifaces)
        if not _is_unix_like_platform():
            if not has_loopback and not has_non_loopback:
                # no flags found, otherwise one of them should be True.
                doctor_warn(
                    'Interface flags are not available on Windows. '
                    'Run `ipconfig` to see what interfaces are available.')
                result.add_warning()
                return result
        if not has_loopback:
            doctor_error('No loopback IP address is found.')
            result.add_error()
        if not has_non_loopback:
            doctor_warn('Only loopback IP address is found.')
            result.add_warning()
        if not has_multicast:
            doctor_warn('No multicast IP address is found.')
            result.add_warning()
        return result
Beispiel #2
0
    def check(self):
        """Check network configuration."""
        result = Result()

        has_loopback = False
        has_non_loopback = False
        has_multicast = False
        for interface in psutil.net_if_addrs().keys():
            flags = InterfaceFlags(interface)
            has_loopback |= flags.has_loopback
            has_non_loopback |= flags.has_non_loopback
            has_multicast |= flags.has_multicast

        if os.name != 'posix':
            if not has_loopback and not has_non_loopback:
                # no flags found, otherwise one of them should be True.
                doctor_warn(
                    'Interface flags are not available on Windows. '
                    'Run `ipconfig` to see what interfaces are available.')
                result.add_warning()
                return result
        if not has_loopback:
            doctor_error('No loopback IP address is found.')
            result.add_error()
        if not has_non_loopback:
            doctor_warn('Only loopback IP address is found.')
            result.add_warning()
        if not has_multicast:
            doctor_warn('No multicast IP address is found.')
            result.add_warning()
        return result
Beispiel #3
0
def _check_platform_helper() -> Tuple[str, dict, dict]:
    """
    Check ROS_DISTRO environment variables and distribution installed.

    :return: string of distro name, dict of distribution info, dict of release platforms info
    """
    distro_name = os.environ.get('ROS_DISTRO')
    if not distro_name:
        doctor_error('ROS_DISTRO is not set.')
        return
    distro_name = distro_name.lower()
    u = rosdistro.get_index_url()
    if not u:
        doctor_error(
            'Unable to access ROSDISTRO_INDEX_URL or DEFAULT_INDEX_URL. '
            'Check network setting to make sure machine is connected to internet.'
        )
        return
    i = rosdistro.get_index(u)
    distro_info = i.distributions.get(distro_name)
    if not distro_info:
        doctor_warn(f'Distribution name {distro_name} is not found')
        return
    try:
        distro_data = rosdistro.get_distribution(i, distro_name).get_data()
    except AttributeError:
        distro_data = ''
    return distro_name, distro_info, distro_data
Beispiel #4
0
    def report(self):
        """Print system and ROS network information."""
        # check ifcfg import for windows and osx users
        try:
            ifcfg_ifaces = ifcfg.interfaces()
        except NameError:
            doctor_error(
                'ifcfg is not imported. Unable to generate network report.')
            return Report('')

        network_report = Report('NETWORK CONFIGURATION')
        for iface in ifcfg_ifaces.values():
            for k, v in iface.items():
                if v:
                    network_report.add_to_report(k, v)
        return network_report
    def check(self):
        """Check packages within the directory where command is called."""
        result = Result()
        distro_package_vers = get_distro_package_versions()
        if not distro_package_vers:
            doctor_error('distro packages info is not found.')
            result.add_error()
        local_package_vers = get_local_package_versions()
        if not local_package_vers:
            doctor_error('local package info is not found.')
            result.add_error()
        if result.error != 0:
            return result

        compare_versions(result, local_package_vers, distro_package_vers)
        return result
def get_distro_package_versions() -> dict:
    """
    Return repos info using rosdistro API.

    :return: dictionary of rosdistro package name and version
    """
    distro_name = os.environ.get('ROS_DISTRO')
    if not distro_name:
        doctor_error('ROS_DISTRO is not set.')
        return
    distro_name = distro_name.lower()
    url = rosdistro.get_index_url()
    if not url:
        doctor_error(
            'Unable to access ROSDISTRO_INDEX_URL or DEFAULT_INDEX_URL. '
            'Check network setting to make sure machine is connected to internet.'
        )
        return
    i = rosdistro.get_index(url)
    distro_info = rosdistro.get_distribution(i, distro_name)
    if not distro_info:
        doctor_warn(f'Distribution name {distro_name} is not found')
        return
    try:
        repos_info = distro_info.get_data().get('repositories')
    except AttributeError:
        doctor_warn('No repository information found.')
        return
    distro_package_vers = {}
    for package_name, info in repos_info.items():
        try:
            release = info['release']
            ver = release.get('version')
            if 'packages' in release:
                # Metapackage
                for package in release['packages']:
                    distro_package_vers[package] = ver
            else:
                distro_package_vers[package_name] = ver
        except KeyError:
            pass
    return distro_package_vers
Beispiel #7
0
    def check(self):
        """Check network configuration."""
        result = Result()
        # check ifcfg import for windows and osx users
        try:
            ifcfg_ifaces = ifcfg.interfaces()
        except NameError:
            doctor_error('`ifcfg` module is not imported. '
                         'Unable to run network check.')
            result.add_error()
            return result

        has_loopback, has_non_loopback, has_multicast = _check_network_config_helper(
            ifcfg_ifaces)
        if not _is_unix_like_platform():
            if not has_loopback and not has_non_loopback:
                # no flags found, otherwise one of them should be True.
                doctor_error(
                    'No flags found. '
                    'Run `ipconfig` on Windows or '
                    'install `ifconfig` on Unix to check network interfaces.')
                result.add_error()
                return result
        if not has_loopback:
            doctor_error('No loopback IP address is found.')
            result.add_error()
        if not has_non_loopback:
            doctor_warn('Only loopback IP address is found.')
            result.add_warning()
        if not has_multicast:
            doctor_warn('No multicast IP address is found.')
            result.add_warning()
        return result
Beispiel #8
0
 def check(self):
     """Check publisher and subscriber counts."""
     result = Result()
     to_be_checked = get_topic_names()
     with NodeStrategy(None) as node:
         for topic in to_be_checked:
             for pub in node.get_publishers_info_by_topic(topic):
                 for sub in node.get_subscriptions_info_by_topic(topic):
                     compatibility, reason = qos_check_compatible(
                         pub.qos_profile, sub.qos_profile)
                     reason_message = self._strip_leading_warning_or_error_from_string(
                         reason)
                     if compatibility == QoSCompatibility.WARNING:
                         doctor_warn(
                             f"QoS compatibility warning found on topic '{topic}': "
                             f'{reason_message}')
                         result.add_warning()
                     elif compatibility == QoSCompatibility.ERROR:
                         doctor_error(
                             f"QoS compatibility error found on topic '{topic}': "
                             f'{reason_message}')
                         result.add_error()
     return result
Beispiel #9
0
    def check(self):
        """Check system platform against ROS 2 Distro."""
        result = Result()
        distros = _check_platform_helper()
        if not distros:
            doctor_error('Missing rosdistro info. Unable to check platform.')
            result.add_error()
            return result
        distro_name, distro_info, _ = distros

        # check distro status
        if distro_info.get('distribution_status') == 'prerelease':
            doctor_warn(
                f'Distribution {distro_name} is not fully supported or tested. '
                'To get more consistent features, download a stable version at '
                'https://index.ros.org/doc/ros2/Installation/')
            result.add_warning()
        elif distro_info.get('distribution_status') == 'end-of-life':
            doctor_warn(
                f'Distribution {distro_name} is no longer supported or deprecated. '
                'To get the latest features, download the new versions at '
                'https://index.ros.org/doc/ros2/Installation/')
            result.add_warning()
        return result