Bug 714903 - Fix getLanIp to work with Mac OS X as well instead of dying with an exception. r=jmaher

This commit is contained in:
Kartikaya Gupta 2012-01-03 15:15:02 -05:00
parent 6bda5a9b48
commit 989e6f35d2

View File

@ -500,7 +500,10 @@ class NetworkTools:
return None
def getLanIp(self):
ip = socket.gethostbyname(socket.gethostname())
try:
ip = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
ip = socket.gethostbyname(socket.gethostname() + ".local") # for Mac OS X
if ip.startswith("127.") and os.name != "nt":
interfaces = ["eth0","eth1","eth2","wlan0","wlan1","wifi0","ath0","ath1","ppp0"]
for ifname in interfaces: