mirror of
https://github.com/fairwaves/UHD-Fairwaves.git
synced 2025-10-23 07:42:00 +00:00
Use ip instead of deprecated ifconfig.
Signed-off-by: Max <max.suraev@fairwaves.co>
This commit is contained in:
@@ -137,25 +137,14 @@ def is_valid_fw_image(fw_image):
|
||||
########################################################################
|
||||
# interface discovery and device enumeration
|
||||
########################################################################
|
||||
def command(*args):
|
||||
p = subprocess.Popen(
|
||||
args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
ret = p.wait()
|
||||
verbose = p.stdout.read().decode()
|
||||
if ret != 0: raise Exception(verbose)
|
||||
return verbose
|
||||
|
||||
def get_interfaces():
|
||||
if(platform.system() is "Windows"): return win_get_interfaces()
|
||||
else: return unix_get_interfaces()
|
||||
|
||||
def unix_get_interfaces():
|
||||
ifconfig = command("/sbin/ifconfig")
|
||||
ip_addr_re = "cast\D*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
|
||||
bcasts = re.findall(ip_addr_re, ifconfig)
|
||||
ipint = subprocess.check_output(["/sbin/ip", "-4", "a", "s", "up"])
|
||||
ip_addr_re = "brd\D*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
|
||||
bcasts = re.findall(ip_addr_re, ipint)
|
||||
return bcasts
|
||||
|
||||
def win_get_interfaces():
|
||||
|
Reference in New Issue
Block a user