示例#1
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
示例#2
0
 def check(self):
     """Check publisher and subscriber counts."""
     result = Result()
     to_be_checked = _get_topic_names()
     with DirectNode(None) as node:
         for topic in to_be_checked:
             pub_count = node.count_publishers(topic)
             sub_count = node.count_subscribers(topic)
             if pub_count > sub_count:
                 result.add_warning(
                     'Publisher without subscriber detected on %s.' % topic)
             elif pub_count < sub_count:
                 result.add_warning(
                     'Subscriber without publisher detected on %s.' % topic)
     return result
示例#3
0
 def check(self):
     """Check publisher and subscriber counts."""
     result = Result()
     to_be_checked = _get_topic_names()
     with DirectNode(None) as node:
         for topic in to_be_checked:
             pub_count = node.count_publishers(topic)
             sub_count = node.count_subscribers(topic)
             if pub_count > 0 and sub_count == 0:
                 doctor_warn(
                     f'Publisher without subscriber detected on {topic}.')
                 result.add_warning()
             elif sub_count > 0 and pub_count == 0:
                 doctor_warn(
                     f'Subscriber without publisher detected on {topic}.')
                 result.add_warning()
     return result
def compare_versions(result: Result, local_packages: dict,
                     distro_packages: dict):
    """
    Return warning messages for PackageCheck, and info for PackageReport.

    :param: dictionary of local package name and version
    :param: dictionary of rosdistro package name and version
    :param: boolean value determines which output to populate, msgs or report
    :return: list of warning messages
    """
    missing_req = ''
    missing_local = ''
    for name, local_ver_str in local_packages.items():
        if not local_ver_str:
            missing_local += ' ' + name
            local_ver_str = ''
        required_ver_str = distro_packages.get(name, '')
        if not required_ver_str:
            missing_req += ' ' + name
        local_ver = version.parse(local_ver_str).base_version
        required_ver = version.parse(required_ver_str).base_version
        if local_ver < required_ver:
            doctor_warn(f'{name} has been updated to a new version.'
                        f' local: {local_ver} <'
                        f' required: {required_ver}')
            result.add_warning()
    if missing_req:
        if len(missing_req) > 100:
            doctor_warn('Cannot find required versions of packages: ' +
                        textwrap.shorten(missing_req, width=100) +
                        ' Use `ros2 doctor --report` to see full list.')
        else:
            doctor_warn('Cannot find required versions of packages: ' +
                        missing_req)
    if missing_local:
        if len(missing_local) > 100:
            doctor_warn('Cannot find local versions of packages: ' +
                        textwrap.shorten(missing_local, width=100) +
                        ' Use `ros2 doctor --report` to see full list.')
        else:
            doctor_warn('Cannot find local versions of packages: ' +
                        missing_local)
示例#5
0
    def check(self):
        """Check network configuration."""
        result = Result()
        # check ifcfg import for windows and osx users
        try:
            ifcfg_ifaces = ifcfg.interfaces()
        except NameError:
            result.add_error(
                'ERROR: ifcfg is not imported. Unable to run network check.')
            return result

        has_loopback, has_non_loopback, has_multicast = _check_network_config_helper(
            ifcfg_ifaces)
        if not has_loopback:
            result.add_error('ERROR: No loopback IP address is found.')
        if not has_non_loopback:
            result.add_warning('Only loopback IP address is found.')
        if not has_multicast:
            result.add_warning('No multicast IP address is found.')
        return result
示例#6
0
    def check(self):
        """Check packages within the directory where command is called."""
        result = Result()
        try:
            distro_package_vers = get_distro_package_versions()
            if not distro_package_vers:
                result.add_error('ERROR: distro packages info is not found.')
        except (AttributeError, RuntimeError, URLError):
            result.add_error(
                'ERROR: Unable to fetch package information from rosdistro.')
        local_package_vers = get_local_package_versions()
        if not local_package_vers:
            result.add_error('ERROR: local package info is not found.')
        if result.error != 0:
            return result

        warning_msgs = compare_versions(local_package_vers,
                                        distro_package_vers)
        for msg in warning_msgs:
            result.add_warning(msg)
        return result
示例#7
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
示例#8
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
示例#9
0
    def check(self):
        """Check system platform against ROS 2 Distro."""
        result = Result()
        distros = _check_platform_helper()
        if not distros:
            result.add_error(
                'ERROR: Missing rosdistro info. Unable to check platform.')
            return result
        distro_name, distro_info, _ = distros

        # check distro status
        if distro_info.get('distribution_status') == 'prerelease':
            result.add_warning(
                'Distribution %s is not fully supported or tested. '
                'To get more consistent features, download a stable version at '
                'https://index.ros.org/doc/ros2/Installation/' % distro_name)
        elif distro_info.get('distribution_status') == 'end-of-life':
            result.add_warning(
                'Distribution %s is no longer supported or deprecated. '
                'To get the latest features, download the new versions at '
                'https://index.ros.org/doc/ros2/Installation/' % distro_name)
        return result
示例#10
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
示例#11
0
    def check(self):
        """Check network configuration."""
        result = Result()
        # check ifcfg import for windows and osx users
        try:
            ifcfg_ifaces = ifcfg.interfaces()
        except NameError:
            result.add_error('ERROR: ifcfg is not imported. Unable to run network check.')
            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.
                print('No flags found. \
                    Run `ipconfig` on cmd to check network interfaces.')
                return result
        if not has_loopback:
            result.add_error('ERROR: No loopback IP address is found.')
        if not has_non_loopback:
            result.add_warning('Only loopback IP address is found.')
        if not has_multicast:
            result.add_warning('No multicast IP address is found.')
        return result