skip delay of IP change if it is caused by the "bootup" event - Closes #156
This commit is contained in:
parent
8a0fb060e2
commit
fbe7adb3e4
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue