- system("ifconfig eth0 up")
- system("ifconfig wlan0 down")
- system("ifconfig ath0 down")
- self.getInterfaces()
-
- def checkNetworkState(self):
- # www.dream-multimedia-tv.de, www.heise.de, www.google.de
- return system("ping -c 1 82.149.226.170") == 0 or \
- system("ping -c 1 193.99.144.85") == 0 or \
- system("ping -c 1 209.85.135.103") == 0
-
- def restartNetwork(self):
- iNetwork.deactivateNetworkConfig()
- iNetwork.activateNetworkConfig()
+ self.commands.append("ifconfig eth0 up")
+ self.commands.append("ifconfig wlan0 down")
+ self.commands.append("ifconfig ath0 down")
+ self.commands.append("/etc/init.d/avahi-daemon start")
+ self.resetNetworkConsole.eBatch(self.commands, self.resetNetworkFinished, [mode,callback], debug=True)
+
+ def resetNetworkFinished(self,extra_args):
+ (mode, callback) = extra_args
+ if len(self.resetNetworkConsole.appContainers) == 0:
+ if callback is not None:
+ callback(True,mode)
+
+ def checkNetworkState(self,statecallback):
+ # www.dream-multimedia-tv.de, www.heise.de, www.google.de
+ self.NetworkState = 0
+ cmd1 = "ping -c 1 82.149.226.170"
+ cmd2 = "ping -c 1 193.99.144.85"
+ cmd3 = "ping -c 1 209.85.135.103"
+ self.PingConsole = Console()
+ self.PingConsole.ePopen(cmd1, self.checkNetworkStateFinished,statecallback)
+ self.PingConsole.ePopen(cmd2, self.checkNetworkStateFinished,statecallback)
+ self.PingConsole.ePopen(cmd3, self.checkNetworkStateFinished,statecallback)
+
+ def checkNetworkStateFinished(self, result, retval,extra_args):
+ (statecallback) = extra_args
+ if self.PingConsole is not None:
+ if retval == 0:
+ self.PingConsole = None
+ statecallback(self.NetworkState)
+ else:
+ self.NetworkState += 1
+ if len(self.PingConsole.appContainers) == 0:
+ statecallback(self.NetworkState)
+
+ def restartNetwork(self,callback = None):
+ if self.onRemoteRootFS():
+ if callback is not None:
+ callback(True)
+ return
+ self.restartConsole = Console()
+ self.config_ready = False
+ self.msgPlugins()
+ self.commands = []
+ self.commands.append("/etc/init.d/avahi-daemon stop")
+ for iface in self.ifaces.keys():
+ cmd = "ip addr flush " + iface
+ self.commands.append(cmd)
+ self.commands.append("/etc/init.d/networking stop")
+ self.commands.append("killall -9 udhcpc")
+ self.commands.append("rm /var/run/udhcpc*")
+ self.commands.append("/etc/init.d/networking start")
+ self.commands.append("/etc/init.d/avahi-daemon start")
+ self.restartConsole.eBatch(self.commands, self.restartNetworkFinished, callback, debug=True)
+
+ def restartNetworkFinished(self,extra_args):
+ ( callback ) = extra_args
+ if callback is not None:
+ callback(True)