+ self.ifaces = {}
+ self.configuredInterfaces = {}
+ self.nameservers = []
+ self.getInterfaces()
+ self.ethtool_bin = "/usr/sbin/ethtool"
+ self.container = eConsoleAppContainer()
+
+ def getInterfaces(self):
+ devicesPattern = re_compile('[a-z]+[0-9]+')
+
+ fp = file('/proc/net/dev', 'r')
+ result = fp.readlines()
+ fp.close()
+ for line in result:
+ try:
+ device = devicesPattern.search(line).group()
+ self.ifaces[device] = self.getDataForInterface(device)
+ # Show only UP Interfaces in E2
+ #if self.getAdapterAttribute(device, 'up') is False:
+ # del self.ifaces[device]
+ except AttributeError:
+ pass
+
+ print "self.ifaces:", self.ifaces
+ self.loadNetworkConfig()
+ #self.writeNetworkConfig()
+ #print ord(' ')
+ #for line in result:
+ # print ord(line[0])
+
+ # helper function
+ def regExpMatch(self, pattern, string):
+ if string is None:
+ return None
+ try:
+ return pattern.search(string).group()
+ except AttributeError:
+ None
+
+ # helper function to convert ips from a sring to a list of ints
+ def convertIP(self, ip):
+ strIP = ip.split('.')
+ ip = []
+ for x in strIP:
+ ip.append(int(x))
+ return ip
+
+ def getDataForInterface(self, iface):
+ #ipRegexp = '[0-9]{1,2,3}\.[0-9]{1,2,3}\.[0-9]{1,2,3}\.[0-9]{1,2,3}'
+ ipRegexp = '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
+ ipLinePattern = re_compile('inet addr:' + ipRegexp)
+ netmaskLinePattern = re_compile('Mask:' + ipRegexp)
+ bcastLinePattern = re_compile('Bcast:' + ipRegexp)
+ ipPattern = re_compile(ipRegexp)
+ upPattern = re_compile('UP ')
+ macPattern = re_compile('[0-9]{2}\:[0-9]{2}\:[0-9]{2}\:[0-9]{2}\:[0-9]{2}\:[0-9]{2}')