Something like this should work:
def net_get_ip(): # by Whise """Returns ip if it can""" ip = commands.getoutput("ip -o -4 addr show") x = 0 while True: ip = ip[ip.find("inet "):] ip = ip[5:] ipc = ip[:ip.find("/")] if ipc != '127.0.0.1' and ipc != None and ipc !='1':
return ipc
return _('Cannot get ip')
Something like this should work:
def net_get_ip(): # by Whise getoutput( "ip -o -4 addr show")
"""Returns ip if it can"""
ip = commands.
x = 0
while True:
ip = ip[ip.find("inet "):]
ip = ip[5:]
ipc = ip[:ip.find("/")]
if ipc != '127.0.0.1' and ipc != None and ipc !='1':
return ipc
return _('Cannot get ip')