Comment 9 for bug 618868

Revision history for this message
Michel Leunen (michel-leunen) wrote : Re: sysmonitor screenlet fails to find the computer's IP address

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')