Add working Networkinteface Source/Converter
authorStephan Reichholf <sreichholf@users.schwerkraft.elitedvb.net>
Tue, 3 Feb 2009 22:50:41 +0000 (22:50 +0000)
committerStephan Reichholf <sreichholf@users.schwerkraft.elitedvb.net>
Tue, 3 Feb 2009 22:50:41 +0000 (22:50 +0000)
webinterface/src/WebComponents/Converter/NetworkInfo.py
webinterface/src/WebComponents/Sources/Network.py

index 9f5cd44..215df11 100644 (file)
@@ -7,32 +7,34 @@ class NetworkInfo(Converter, object):
     DHCP = 1
     IP = 2
     GATEWAY = 3
-    NAMESERVER = 4
+    NETMASK = 4
     
     def __init__(self, type):
-        Converter.___init__(self)
+        Converter.__init__(self, type)
         self.type = {
                      "Mac" : self.MAC,
                      "Dhcp" : self.DHCP,
                      "Ip" : self.IP,
                      "Gateway" : self.GATEWAY,
-                     "Nameserver" : self.NAMESERVER,
+                     "Netmask" : self.NETMASK,
                      }[type]
     
     @cached
     def getText(self):
-        iface = iface.interface
+        iface = self.source.interface
         
         if self.type is self.MAC:
             return iface.mac
         elif self.type is self.DHCP:
             return iface.dhcp
         elif self.type is self.IP:
-            return iface.IP
+            return iface.ip
         elif self.type is self.GATEWAY:
             return iface.gateway
-        elif self.type is self.NAMESERVER:
-            return iface.nameserver
+        elif self.type is self.NETMASK:
+            return iface.netmask
+        else:
+            return _("N/A")
         
     text = property(getText)
     
\ No newline at end of file
index 60d8861..4ccfa76 100644 (file)
@@ -1,6 +1,6 @@
 from Components.Sources.Source import Source
 from Components.Network import iNetwork
-from Components.Element import cached
+#from Components.Element import cached
 
 
 class Network(Source):
@@ -13,13 +13,24 @@ class Network(Source):
             self.iface = "eth0"
         elif device is self.WLAN:
             self.iface = "ath0"
-    @cached        
+            
+            
+            #Get Network Info
+    def ConvertIP(self, list):
+        if(len(list) == 4):
+            retstr = "%s.%s.%s.%s" %(list[0], list[1], list[2], list[3])
+        else:
+            retstr = "0.0.0.0"
+        return retstr
+#    @cached        
     def getInterface(self):
         self.mac =  iNetwork.getAdapterAttribute(self.iface, "mac")
         self.dhcp = iNetwork.getAdapterAttribute(self.iface, "dhcp")
-        self.ip = ConvertIP(iNetwork.getAdapterAttribute(self.iface, "ip"))
-        self.netmask = ConvertIP(iNetwork.getAdapterAttribute(self.iface, "netmask"))
-        self.gateway = ConvertIP(iNetwork.getAdapterAttribute(self.iface, "gateway"))
+        self.ip = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "ip"))
+        self.netmask = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "netmask"))
+        self.gateway = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "gateway"))
+        
+        return self
         
     interface = property(getInterface)