def network_state(device):
    try:
        output = subprocess.check_output(
            ["tc", "qdisc", "show", "dev", device]).decode()
        # sloppy but good enough for now
        if output in " delay ":
            return NetworkState.SLOW
        if " loss " in output:
            return NetworkState.FLAKY
        if " duplicate " in output:
            return NetworkState.DUPLICATE
        return NetworkState.NORMAL

    except subprocess.CalledProcessError:
        # TODO log error somewhere?
        return NetworkState.UNKNOWN
dataset/ETHPy150Open dcm-oss/blockade/blockade/net.py/network_state/swapped operands of `in`