ros2 / ros2cli

ROS 2 command line interface tools
Apache License 2.0
166 stars 158 forks source link

Revamp how we get network information in ros2doctor. #910

Closed clalancette closed 1 month ago

clalancette commented 1 month ago

We already depend on psutil, which can give us information for ros2doctor in a cross-platform way. Lean more heavily into using this, which should help us deal with cross-platform a little more smoothly.

I will note that this slightly changes the output of ros2doctor on Linux. Prior to this PR, the flags output would look something like:

flags        : 4163<MULTICAST,BROADCAST,UP,RUNNING>

After this PR, the output looks like this:

flags        : UP,BROADCAST,RUNNING,MULTICAST

That is, we lose the decimal bitmask associated with the device.

This should fix #906

clalancette commented 1 month ago

CI:

clalancette commented 1 month ago

Another CI after the fix to flake8:

clalancette commented 1 month ago

Going ahead and merging this one in, thanks for the review.

fujitatomoya commented 1 month ago

@clalancette what do you say backport to jazzy, iron and humble? looks like they all have this problem and already use psutil, so it should be straight-forward. if that is fine, i can take care of backports.

clalancette commented 1 month ago

@clalancette what do you say backport to jazzy, iron and humble? looks like they all have this problem and already use psutil, so it should be straight-forward. if that is fine, i can take care of backports.

The big problem with doing that is that we'd change the output on an already-released distribution. I guess we could kind of reconstruct that information there by putting the POSIX_NET_FLAGS back and mapping from strings to hex numbers, but that would be wrong on macOS.

fujitatomoya commented 1 month ago

ah that is true. this changes the format, there could be some script or tools relying on the current format for released distros. okay, i am not gonna do this at this moment.