Add working Networkinteface Source/Converter
[enigma2-plugins.git] / webinterface / src / WebComponents / Converter / NetworkInfo.py
1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
3
4
5 class NetworkInfo(Converter, object):
6     MAC = 0
7     DHCP = 1
8     IP = 2
9     GATEWAY = 3
10     NETMASK = 4
11     
12     def __init__(self, type):
13         Converter.__init__(self, type)
14         self.type = {
15                      "Mac" : self.MAC,
16                      "Dhcp" : self.DHCP,
17                      "Ip" : self.IP,
18                      "Gateway" : self.GATEWAY,
19                      "Netmask" : self.NETMASK,
20                      }[type]
21     
22     @cached
23     def getText(self):
24         iface = self.source.interface
25         
26         if self.type is self.MAC:
27             return iface.mac
28         elif self.type is self.DHCP:
29             return iface.dhcp
30         elif self.type is self.IP:
31             return iface.ip
32         elif self.type is self.GATEWAY:
33             return iface.gateway
34         elif self.type is self.NETMASK:
35             return iface.netmask
36         else:
37             return _("N/A")
38         
39     text = property(getText)
40