From ac31507f15c0ee02fc13c9d3b00a4f92834701f9 Mon Sep 17 00:00:00 2001 From: Marc Fiuczynski Date: Tue, 2 Mar 2010 15:23:18 +0000 Subject: [PATCH] updated gifconf() function --- sioc.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sioc.py b/sioc.py index d596f77..489a93e 100644 --- a/sioc.py +++ b/sioc.py @@ -41,9 +41,18 @@ def gifconf(): (stdout, stderr) = ip.communicate() ip.wait() for line in stdout.split("\n"): - if line.startswith(" inet "): - fields = line.split(" ") - ret[fields[-1]] = fields[5].split("/")[0] + line = line.strip() + if line =='':continue + + fields = line.split(" ") + # clean up fields + for i in range(0,len(fields)): fields[i]=fields[i].strip() + + if fields[0] == "inet": + # fields[-1] is the last column in fields, which has the interface name + # fields[1] has the IP address + ret[fields[-1]] = fields[1].split("/")[0] + return ret def gifhwaddr(interface): -- 2.43.0