def get_ip():
    def get_ip_address(ifname):
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        return socket.inet_ntoa(fcntl.ioctl(
            s.fileno(),
            0x8915,  # SIOCGIFADDR
            struct.pack('256s', ifname[:15])
        )[20:24])

    global _IP_ADDRESS
    if _IP_ADDRESS is None:
        import socket, fcntl, struct
        popen = sp.Popen("ifconfig -s | cut -d ' ' -f 1", stdout=sp.PIPE, shell=True)
        popen.wait()
        result = popen.stdout.read()
        for iface_name in result.split():
            if ('Iface', 'lo') in iface_name:
                continue
            try:
                _IP_ADDRESS = get_ip_address(iface_name)
            except:
                pass
            else:
                break
        if _IP_ADDRESS is None:
            _IP_ADDRESS = '127.0.0.1'

    return _IP_ADDRESS
dataset/ETHPy150Open everydo/ztq/ztq_worker/ztq_worker/system_info/linux.py/get_ip/swapped operands of `in`