aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python')
-rwxr-xr-xlib/python/Components/Network.py31
-rwxr-xr-xlib/python/Screens/NetworkSetup.py42
2 files changed, 45 insertions, 28 deletions
diff --git a/lib/python/Components/Network.py b/lib/python/Components/Network.py
index e317ef05..c41469da 100755
--- a/lib/python/Components/Network.py
+++ b/lib/python/Components/Network.py
@@ -18,6 +18,7 @@ class Network:
self.LinkConsole = Console()
self.restartConsole = Console()
self.deactivateConsole = Console()
+ self.deactivateInterfaceConsole = Console()
self.activateConsole = Console()
self.resetNetworkConsole = Console()
self.DnsConsole = Console()
@@ -74,7 +75,7 @@ class Network:
macRegexp = '[0-9]{2}\:[0-9]{2}\:[0-9]{2}\:[a-z0-9]{2}\:[a-z0-9]{2}\:[a-z0-9]{2}'
ipLinePattern = re_compile('inet ' + ipRegexp + '/')
ipPattern = re_compile(ipRegexp)
- netmaskLinePattern = re_compile(ipRegexp + '/' + netRegexp)
+ netmaskLinePattern = re_compile('/' + netRegexp)
netmaskPattern = re_compile(netRegexp)
bcastLinePattern = re_compile(' brd ' + ipRegexp)
upPattern = re_compile('UP')
@@ -412,7 +413,7 @@ class Network:
if len(self.PingConsole.appContainers) == 0:
statecallback(self.NetworkState)
- def restartNetwork(self,callback):
+ def restartNetwork(self,callback = None):
self.restartConsole = Console()
self.commands = []
self.commands.append("/etc/init.d/avahi-daemon stop")
@@ -427,8 +428,8 @@ class Network:
self.restartConsole.eBatch(self.commands, self.restartNetworkFinished, callback, debug=True)
def restartNetworkFinished(self,extra_args):
- callback = extra_args
- if len(self.restartConsole.appContainers) == 0:
+ ( callback ) = extra_args
+ if callback is not None:
callback(True)
def getLinkState(self,iface,callback):
@@ -454,12 +455,13 @@ class Network:
if self.restartConsole is not None:
self.restartConsole = None
- def RestartConsoleRunning(self):
- if self.restartConsole is not None:
- if len(self.restartConsole.appContainers) == 0:
- return False
- else:
- return True
+ def stopGetInterfacesConsole(self):
+ if self.Console is not None:
+ self.Console = None
+
+ def stopDeactivateInterfaceConsole(self):
+ if self.deactivateInterfaceConsole:
+ self.deactivateInterfaceConsole = None
def checkforInterface(self,iface):
if self.getAdapterAttribute(iface, 'up') is True:
@@ -492,17 +494,20 @@ class Network:
if len(self.DnsConsole.appContainers) == 0:
statecallback(self.DnsState)
- def deactivateInterface(self,iface):
+ def deactivateInterface(self,iface,callback = None):
self.deactivateInterfaceConsole = Console()
self.commands = []
cmd1 = "ip addr flush " + iface
cmd2 = "ifconfig " + iface + " down"
self.commands.append(cmd1)
self.commands.append(cmd2)
- self.deactivateInterfaceConsole.eBatch(self.commands, self.deactivateInterfaceFinished, extra_args = None, debug=True)
+ self.deactivateInterfaceConsole.eBatch(self.commands, self.deactivateInterfaceFinished, callback, debug=True)
def deactivateInterfaceFinished(self,extra_args):
- pass
+ callback = extra_args
+ if len(self.deactivateInterfaceConsole.appContainers) == 0:
+ if callback is not None:
+ callback(True)
def detectWlanModule(self):
self.wlanmodule = None
diff --git a/lib/python/Screens/NetworkSetup.py b/lib/python/Screens/NetworkSetup.py
index 619db4e1..887e1674 100755
--- a/lib/python/Screens/NetworkSetup.py
+++ b/lib/python/Screens/NetworkSetup.py
@@ -285,13 +285,12 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
self.finished_cb = None
self.oktext = _("Press OK on your remote control to continue.")
self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
- #iNetwork.getInterfaces()
self.createConfig()
self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
{
- "cancel": (self.close, _("exit networkadapter setup menu")),
+ "cancel": (self.cancel, _("exit networkadapter setup menu")),
"ok": (self.ok, _("select menu entry")),
})
@@ -413,7 +412,6 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
self.aps = self.w.getNetworkList()
if self.aps is not None:
print "[NetworkSetup.py] got Accespoints!"
- #print self.aps
for ap in self.aps:
a = self.aps[ap]
if a['active']:
@@ -638,17 +636,26 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
self.applyConfig(True)
def ConfigfinishedCB(self,data):
- if data is True:
- self.close('ok')
+ if data is not None:
+ if data is True:
+ self.close('ok')
def cancel(self):
- iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
- self.activateInterfaceEntry.value = self.oldInterfaceState
- if self.activateInterfaceEntry.value is False:
- iNetwork.deactivateInterface(self.iface)
- iNetwork.getInterfaces()
- self.close('cancel')
+ if self.oldInterfaceState is False:
+ iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB)
+ else:
+ self.close('cancel')
+ def deactivateInterfaceCB(self,data):
+ if data is not None:
+ if data is True:
+ iNetwork.getInterfaces(self.cancelCB)
+
+ def cancelCB(self,data):
+ if data is not None:
+ if data is True:
+ self.close('cancel')
+
def runAsync(self, finished_cb):
self.finished_cb = finished_cb
self.ok()
@@ -663,7 +670,8 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
def cleanup(self):
iNetwork.stopLinkStateConsole()
- iNetwork.stopRestartConsole()
+ iNetwork.stopDeactivateInterfaceConsole()
+
class AdapterSetupConfiguration(Screen, HelpableScreen):
def __init__(self, session,iface):
@@ -722,7 +730,6 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
iNetwork.getInterfaces(self.updateStatusbar)
self.onLayoutFinish.append(self.layoutFinished)
self.onClose.append(self.cleanup)
- self.onHide.append(self.cleanup)
def ok(self):
if self["menulist"].getCurrent()[1] == 'edit':
@@ -914,8 +921,12 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
if ret[0] is not None:
self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
else:
- self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,None,None)
-
+ from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
+ iStatus.stopWlanConsole()
+ self.mainmenu = self.genMainMenu()
+ self["menulist"].l.setList(self.mainmenu)
+ iNetwork.getInterfaces(self.updateStatusbar)
+
def restartLan(self, ret = False):
if (ret == True):
iNetwork.restartNetwork(self.restartLanDataAvail)
@@ -949,6 +960,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
def cleanup(self):
iNetwork.stopLinkStateConsole()
+ iNetwork.stopDeactivateInterfaceConsole()
try:
from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
except ImportError: