only run ip on linux
This commit is contained in:
parent
3c58e95948
commit
a3f6e3da3a
1 changed files with 1 additions and 1 deletions
|
@ -239,7 +239,7 @@ def get_local_ipv4():
|
||||||
ips = [l for l in stdout.split('\n') if 'inet ' in l]
|
ips = [l for l in stdout.split('\n') if 'inet ' in l]
|
||||||
if ips:
|
if ips:
|
||||||
ip = ips[0].strip().split(' ')[1]
|
ip = ips[0].strip().split(' ')[1]
|
||||||
else:
|
elif sys.platform.startswith('linux'):
|
||||||
cmd = ['ip', 'route', 'show']
|
cmd = ['ip', 'route', 'show']
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
|
|
Loading…
Reference in a new issue