mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More robust host IP detection when building calibre
This commit is contained in:
parent
4d2ed78698
commit
309668f077
@ -11,7 +11,7 @@ from distutils.spawn import find_executable
|
|||||||
|
|
||||||
from PyQt4 import pyqtconfig
|
from PyQt4 import pyqtconfig
|
||||||
|
|
||||||
from setup import isosx, iswindows, islinux, is64bit
|
from setup import isosx, iswindows, is64bit
|
||||||
is64bit
|
is64bit
|
||||||
|
|
||||||
OSX_SDK = '/Developer/SDKs/MacOSX10.5.sdk'
|
OSX_SDK = '/Developer/SDKs/MacOSX10.5.sdk'
|
||||||
@ -189,19 +189,19 @@ def get_ip_address(ifname):
|
|||||||
struct.pack('256s', ifname[:15])
|
struct.pack('256s', ifname[:15])
|
||||||
)[20:24])
|
)[20:24])
|
||||||
|
|
||||||
try:
|
|
||||||
if islinux:
|
|
||||||
HOST=get_ip_address('eth0')
|
|
||||||
else:
|
|
||||||
HOST='192.168.1.2'
|
HOST='192.168.1.2'
|
||||||
except:
|
|
||||||
try:
|
try:
|
||||||
HOST=get_ip_address('wlan0')
|
import netifaces
|
||||||
except:
|
for iface in netifaces.interfaces():
|
||||||
try:
|
addrs = netifaces.ifaddresses(iface).get(netifaces.AF_INET, [])
|
||||||
HOST=get_ip_address('ppp0')
|
if len(addrs) > 0 and 'addr' in addrs[0]:
|
||||||
except:
|
q = addrs[0]['addr']
|
||||||
HOST='192.168.1.2'
|
if q.startswith('192.168.1.'):
|
||||||
|
HOST = q
|
||||||
|
break
|
||||||
|
except (Exception, ImportError) as e:
|
||||||
|
print ('Failed to detect host ip address with error: %s' % e)
|
||||||
|
|
||||||
|
|
||||||
PROJECT=os.path.basename(os.path.abspath('.'))
|
PROJECT=os.path.basename(os.path.abspath('.'))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user