MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / get_lan_ip

Function get_lan_ip

py/test/selenium/webdriver/common/network.py:36–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34
35
36def get_lan_ip():
37 if os.environ.get("CI") == "true":
38 return "0.0.0.0"
39
40 try:
41 ip = socket.gethostbyname(socket.gethostname())
42 except Exception:
43 return "0.0.0.0"
44 if ip.startswith("127.") and os.name != "nt":
45 interfaces = [
46 "eth0",
47 "eth1",
48 "eth2",
49 "en0",
50 "en1",
51 "en2",
52 "en3",
53 "en4",
54 "eno0",
55 "eno1",
56 "eno2",
57 "eno3",
58 "eno4",
59 "wlan0",
60 "wlan1",
61 "wifi0",
62 "ath0",
63 "ath1",
64 "ppp0",
65 ]
66 for ifname in interfaces:
67 try:
68 ip = get_interface_ip(ifname)
69 break
70 except OSError:
71 pass
72 return ip

Callers 1

webserverFunction · 0.90

Calls 2

get_interface_ipFunction · 0.85
getMethod · 0.65

Tested by 1

webserverFunction · 0.72