- # this will call the "setup-val" initial
- config.network.dhcp.addNotifier(setDHCP)
- config.network.ip.addNotifier(setIPAddress)
- config.network.netmask.addNotifier(setNetmask)
- config.network.gateway.addNotifier(setGateway)
- config.network.dns.addNotifier(setIPNameserver)
- config.network.mac.addNotifier(setMACAddress)
+ def restartNetwork(self):
+ iNetwork.deactivateNetworkConfig()
+ iNetwork.activateNetworkConfig()
+
+ def getLinkState(self,iface,callback):
+ self.dataAvail = callback
+ cmd = self.ethtool_bin + " " + iface
+ self.container.appClosed.get().append(self.cmdFinished)
+ self.container.dataAvail.get().append(callback)
+ self.container.execute(cmd)
+
+ def cmdFinished(self,retval):
+ self.container.appClosed.get().remove(self.cmdFinished)
+ self.container.dataAvail.get().remove(self.dataAvail)
+
+ def checkforInterface(self,iface):
+ if self.getAdapterAttribute(iface, 'up') is True:
+ return True
+ else:
+ ret=system("ifconfig " + iface + " up")
+ system("ifconfig " + iface + " down")
+ if ret == 0:
+ return True
+ else:
+ return False
+
+ def checkDNSLookup(self):
+ return system("nslookup www.dream-multimedia-tv.de") == 0 or \
+ system("nslookup www.heise.de") == 0 or \
+ system("nslookup www.google.de")
+
+ def deactivateInterface(self,iface):
+ system("ifconfig " + iface + " down")
+
+ def detectWlanModule(self):
+ self.wlanmodule = None
+ rt73_dir = "/sys/bus/usb/drivers/rt73/"
+ zd1211b_dir = "/sys/bus/usb/drivers/zd1211b/"
+ madwifi_dir = "/sys/bus/pci/drivers/ath_pci/"
+ if os_path.exists(madwifi_dir):
+ files = listdir(madwifi_dir)
+ if len(files) >= 1:
+ self.wlanmodule = 'madwifi'
+ elif os_path.exists(rt73_dir):
+ files = listdir(rt73_dir)
+ if len(files) >= 1:
+ self.wlanmodule = 'ralink'
+ elif os_path.exists(zd1211b_dir):
+ files = listdir(zd1211b_dir)
+ if len(files) != 0:
+ self.wlanmodule = 'zydas'
+ return self.wlanmodule
+
+
+iNetwork = Network()
+
+def InitNetwork():
+ pass