##// END OF EJS Templates
Fix loading IP addresses from subprocess output
Thomas Kluyver -
Show More
@@ -27,7 +27,6 b' import socket'
27
27
28 from .data import uniq_stable
28 from .data import uniq_stable
29 from .process import get_output_error_code
29 from .process import get_output_error_code
30 from .py3compat import bytes_to_str
31 from .warn import warn
30 from .warn import warn
32
31
33 #-----------------------------------------------------------------------------
32 #-----------------------------------------------------------------------------
@@ -96,11 +95,11 b' def _load_ips_ifconfig():'
96 if rc:
95 if rc:
97 raise IOError("no ifconfig: %s" % err)
96 raise IOError("no ifconfig: %s" % err)
98
97
99 lines = bytes_to_str(out).splitlines()
98 lines = out.splitlines()
100 addrs = []
99 addrs = []
101 for line in lines:
100 for line in lines:
102 blocks = line.lower().split()
101 blocks = line.lower().split()
103 if blocks[0] == 'inet':
102 if (len(blocks) >= 2) and (blocks[0] == 'inet'):
104 addrs.append(blocks[1])
103 addrs.append(blocks[1])
105 _populate_from_list(addrs)
104 _populate_from_list(addrs)
106
105
@@ -111,11 +110,11 b' def _load_ips_ip():'
111 if rc:
110 if rc:
112 raise IOError("no ip: %s" % err)
111 raise IOError("no ip: %s" % err)
113
112
114 lines = bytes_to_str(out).splitlines()
113 lines = out.splitlines()
115 addrs = []
114 addrs = []
116 for line in lines:
115 for line in lines:
117 blocks = line.lower().split()
116 blocks = line.lower().split()
118 if blocks[0] == 'inet':
117 if (len(blocks) >= 2) and (blocks[0] == 'inet'):
119 addrs.append(blocks[1].split('/')[0])
118 addrs.append(blocks[1].split('/')[0])
120 _populate_from_list(addrs)
119 _populate_from_list(addrs)
121
120
@@ -126,7 +125,7 b' def _load_ips_ipconfig():'
126 if rc:
125 if rc:
127 raise IOError("no ipconfig: %s" % err)
126 raise IOError("no ipconfig: %s" % err)
128
127
129 lines = bytes_to_str(out).splitlines()
128 lines = out.splitlines()
130 addrs = ['127.0.0.1']
129 addrs = ['127.0.0.1']
131 for line in lines:
130 for line in lines:
132 line = line.lower().split()
131 line = line.lower().split()
General Comments 0
You need to be logged in to leave comments. Login now