Browse Source

do not write config file from network class

283
ThomasV 10 years ago
parent
commit
98cc9c53d1
  1. 12
      lib/network.py
  2. 14
      lib/network_proxy.py

12
lib/network.py

@ -308,15 +308,6 @@ class Network(util.DaemonThread):
def set_parameters(self, host, port, protocol, proxy, auto_connect):
proxy_str = serialize_proxy(proxy)
server_str = serialize_server(host, port, protocol)
self.config.set_key('auto_cycle', auto_connect, True)
self.config.set_key("proxy", proxy_str, True)
self.config.set_key("server", server_str, True)
# abort if changes were not allowed by config
if self.config.get('server') != server_str or self.config.get('proxy') != proxy_str:
return
if self.proxy != proxy or self.protocol != protocol:
self.print_error('restarting network')
for i in self.interfaces.values():
@ -336,6 +327,7 @@ class Network(util.DaemonThread):
if self.server_is_lagging():
self.stop_interface()
else:
server_str = serialize_server(host, port, protocol)
self.set_server(server_str)
@ -352,7 +344,6 @@ class Network(util.DaemonThread):
server = interface.server
self.print_error("switching to", server)
self.interface = interface
self.config.set_key('server', server, False)
self.default_server = server
self.send_subscriptions()
self.set_status('connected')
@ -378,7 +369,6 @@ class Network(util.DaemonThread):
self.set_status('connecting')
# start interface
self.default_server = server
self.config.set_key("server", server, True)
if server in self.interfaces.keys():
self.switch_to_interface( self.interfaces[server] )

14
lib/network_proxy.py

@ -30,6 +30,7 @@ from network import Network
from util import print_error, print_stderr, parse_json
from simple_config import SimpleConfig
from daemon import NetworkServer
from network import serialize_proxy, serialize_server
@ -205,8 +206,17 @@ class NetworkProxy(util.DaemonThread):
def get_parameters(self):
return self.synchronous_get([('network.get_parameters', [])])[0]
def set_parameters(self, *args):
return self.synchronous_get([('network.set_parameters', args)])[0]
def set_parameters(self, host, port, protocol, proxy, auto_connect):
proxy_str = serialize_proxy(proxy)
server_str = serialize_server(host, port, protocol)
self.config.set_key('auto_cycle', auto_connect, True)
self.config.set_key("proxy", proxy_str, True)
self.config.set_key("server", server_str, True)
# abort if changes were not allowed by config
if self.config.get('server') != server_str or self.config.get('proxy') != proxy_str:
return
return self.synchronous_get([('network.set_parameters', (host, port, protocol, proxy, auto_connect))])[0]
def stop_daemon(self):
return self.send([('daemon.stop',[])], None)

Loading…
Cancel
Save