Skip to content

Commit

Permalink
Update network check to fix missing flags on Windows (#404)
Browse files Browse the repository at this point in the history
* add no flags scenario
  • Loading branch information
Claire Wang committed Nov 20, 2019
1 parent b0c9f3c commit 6cd4868
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ros2doctor/ros2doctor/api/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _is_unix_like_platform() -> bool:
def _check_network_config_helper(ifcfg_ifaces: dict) -> Tuple[bool, bool, bool]:
"""Check if loopback and multicast IP addresses are found."""
has_loopback, has_non_loopback, has_multicast = False, False, False
for _, iface in ifcfg.interfaces().items():
for iface in ifcfg_ifaces.values():
flags = iface.get('flags')
if flags:
flags = flags.lower()
Expand Down Expand Up @@ -66,6 +66,12 @@ def check(self):
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:
Expand All @@ -91,7 +97,7 @@ def report(self):
return Report('')

network_report = Report('NETWORK CONFIGURATION')
for name, iface in ifcfg_ifaces.items():
for iface in ifcfg_ifaces.values():
for k, v in iface.items():
if v:
network_report.add_to_report(k, v)
Expand Down

0 comments on commit 6cd4868

Please sign in to comment.