From fbe7adb3e4b2f77e52ee60746e756483b4f3393d Mon Sep 17 00:00:00 2001 From: lars Date: Thu, 21 Jun 2007 02:15:17 +0000 Subject: [PATCH] skip delay of IP change if it is caused by the "bootup" event - Closes #156 --- plugins/network/network.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/network/network.py b/plugins/network/network.py index 7f81b56..ccdbc3e 100644 --- a/plugins/network/network.py +++ b/plugins/network/network.py @@ -144,7 +144,10 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): if event == "bootup": if "_address" in self.prefs: if "_netmask" in self.prefs: - self.__set_ip(self.prefs["_address"], self.prefs["_netmask"]) + ## change the ip without any delay - otherwise the following + ## gateway setting will fail, if the network range changes + self.__set_ip(self.prefs["_address"], self.prefs["_netmask"], + change_delay=0) else: ## no netmask setting stored self.__set_ip(self.prefs["_address"]) @@ -269,16 +272,19 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): return (0, 0, 0, 0) - def __set_ip(self, new_ip, new_nm="255.255.255.0"): + def __set_ip(self, new_ip, new_nm="255.255.255.0", change_delay=None): """Change the IP, additionally a netmask can be applied """ import threading + if change_delay is None: + change_delay = CHANGE_IP_DELAY ## call the root_action script after some seconds - so we can deliver the page before def delayed_ip_change(): """A threaded function to change the IP. """ import time - time.sleep(CHANGE_IP_DELAY) + if change_delay > 0: + time.sleep(change_delay) proc = subprocess.Popen( shell = False, stderr = subprocess.PIPE,