Bug 714903 - Fix getLanIp to work with Mac OS X as well instead of dying with an exception. r=jmaher
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 03 Jan 2012 15:15:02 -0500
changeset 84928 cc4c6c59c516968e11c7648e35fec573c9147b1c
parent 84927 042e74585d41c807fbc224cf9c543bb71a6397f2
child 84929 ef2409ee1e0e52033c0383b641aa5208c80b911f
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs714903
milestone12.0a1
Bug 714903 - Fix getLanIp to work with Mac OS X as well instead of dying with an exception. r=jmaher
build/mobile/devicemanager.py
--- a/build/mobile/devicemanager.py
+++ b/build/mobile/devicemanager.py
@@ -495,17 +495,20 @@ class NetworkTools:
                               s.fileno(),
                               0x8915,  # SIOCGIFADDR
                               struct.pack('256s', ifname[:15])
                               )[20:24])
     else:
       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:
         try:
           ip = self.getInterfaceIp(ifname)
           break;
         except IOError:
           pass