def _get_ip_addr(self): if not self._ip_addr: ifaces = platform.net_interfaces() try: self._ip_addr = [iface["ipv4"] for iface in ifaces if platform.is_private_ip(iface["ipv4"])][0] except IndexError: try: self._ip_addr = [iface["ipv4"] for iface in ifaces if platform.is_public_ip(iface["ipv4"])][0] except IndexError: pass return self._ip_addr
def _get_ip_addr(self): if not self._ip_addr: ifaces = platform.net_interfaces() try: self._ip_addr = [ iface['ipv4'] for iface in ifaces if platform.is_private_ip(iface['ipv4']) ][0] except IndexError: try: self._ip_addr = [ iface['ipv4'] for iface in ifaces if platform.is_public_ip(iface['ipv4']) ][0] except IndexError: pass return self._ip_addr
def get_public_ip(self): if self._public_ip is None: ifaces = platform.net_interfaces() self._public_ip = ifaces[ 'eth0'] if 'eth1' in ifaces and 'eth0' in ifaces else '' return self._public_ip
def get_private_ip(self): if self._private_ip is None: ifaces = platform.net_interfaces() self._private_ip = ifaces['eth1' if 'eth1' in ifaces else 'eth0'] return self._private_ip
def get_public_ip(self): if self._public_ip is None: ifaces = platform.net_interfaces() self._public_ip = ifaces['eth0'] if 'eth1' in ifaces and 'eth0' in ifaces else '' return self._public_ip