MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / get_active_ethernet_interface

Function get_active_ethernet_interface

wifi_interfaces.py:390–400  ·  view source on GitHub ↗

Get the first active (connected with carrier) Ethernet interface. Note: Interfaces with link-local IPs (169.254.x.x) are not considered active.

()

Source from the content-addressed store, hash-verified

388
389
390def get_active_ethernet_interface() -> Optional[Dict]:
391 """Get the first active (connected with carrier) Ethernet interface.
392
393 Note: Interfaces with link-local IPs (169.254.x.x) are not considered active.
394 """
395 ethernet_interfaces = gather_ethernet_interfaces()
396 for iface in ethernet_interfaces:
397 ip_addr = iface.get('ip_address')
398 if iface.get('connected') and iface.get('has_carrier') and ip_addr and not is_link_local_ip(ip_addr):
399 return iface
400 return None
401
402
403def is_ethernet_available() -> bool:

Callers 4

_get_active_ethernet_ipFunction · 0.90
is_ethernet_availableFunction · 0.85

Calls 3

is_link_local_ipFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected