addressManager: remove old style ifconfig

This commit is contained in:
uhi22 2023-05-26 09:12:26 +02:00
parent 2f68d6a76f
commit ea45451c28

View file

@ -58,23 +58,7 @@ class addressManager():
foundAddresses.append(line[k+1:])
else:
# on Raspberry
cfg_useOldStyleIfconfig = 0
if (cfg_useOldStyleIfconfig!=0):
result = subprocess.run(["ifconfig"], capture_output=True, text=True)
if (len(result.stderr)>0):
print(result.stderr)
else:
lines = result.stdout.split("\n")
for line in lines:
if (line.strip().find("inet6")>0):
k = line.strip().find("fe80::") # the beginning of the IPv6
if (k>0):
sIpWithText = line[k+1:]
x = sIpWithText.find(" ") # the space is the end of the IPv6
sIp = sIpWithText[0:x]
# print("[addressManager] IP=>" + sIp + "<")
foundAddresses.append(sIp)
else: # instead of the deprecated ifconfig, use "ip addr"
# instead of the deprecated ifconfig, use "ip addr"
result = subprocess.run(["ip", "addr"], capture_output=True, text=True)
if (len(result.stderr)>0):
print(result.stderr)