@staticmethod
    def get_main_iface():
        def make_route(line):
            return dict(zip(['iface', 'dest'], line.split()))
        with open('/proc/net/route', 'r') as fp:
            lines = fp.readlines()
        routes = [make_route(line) for line in lines[1:]]
        try:
            return next(
                (r for r in routes if not int(r['dest'], 16)),
                routes[0]
            )['iface']
        except (__HOLE__, IndexError, ValueError):
            raise RuntimeError('No valid interfaces available')
dataset/ETHPy150Open qtile/qtile/libqtile/widget/graph.py/NetGraph.get_main_iface