(net_if, ip_addr)
return has_ip, ip_ok
Check if interface has IP and if it matches target IP

    Args:
        net_if  : DVB network interface name
        ip_addr : Target IP address for the DVB interface slash subnet mask

    Returns:
        (Bool, Bool) Tuple of booleans. The first indicates whether interface
        already has an IP. The second indicates whether the interface IP (if
        existing) matches with respect to a target IP.
Check if interface has IP and if it matches target IP
Check if interface has IP and if it matches target IP
def _check_ip(net_if, ip_addr):
    """Check if interface has IP and if it matches target IP

    Args:
        net_if  : DVB network interface name
        ip_addr : Target IP address for the DVB interface slash subnet mask

    Returns:
        (Bool, Bool) Tuple of booleans. The first indicates whether interface
        already has an IP. The second indicates whether the interface IP (if
        existing) matches with respect to a target IP.

    """
    try:
        res = subprocess.check_output(["ip", "addr", "show", "dev", net_if],
                                      stderr=subprocess.DEVNULL)
    except subprocess.CalledProcessError:
        return False, False

    has_ip = False
    ip_ok = False
    for line in res.splitlines():
        if "inet" in line.decode() and "inet6" not in line.decode():
            has_ip = True
            # Check if IP matches target
            inet_info = line.decode().split()
            inet_if = IPv4Interface(inet_info[1])
            target_if = IPv4Interface(ip_addr)
            ip_ok = (inet_if == target_if)
            break

    return has_ip, ip_ok
def _check_ip ( net_if , ip_addr ) : try : res = subprocess . check_output ( [ "ip" , "addr" , "show" , "dev" , net_if ] , stderr = subprocess . DEVNULL ) except subprocess . CalledProcessError : return False , False has_ip = False ip_ok = False for line in res . splitlines ( ) : if "inet" in line . decode ( ) and "inet6" not in line . decode ( ) : has_ip = True # Check if IP matches target inet_info = line . decode ( ) . split ( ) inet_if = IPv4Interface ( inet_info [ 1 ] ) target_if = IPv4Interface ( ip_addr ) ip_ok = ( inet_if == target_if ) break return has_ip , ip_ok