handle network.interface being None when network is disconnected
This commit is contained in:
parent
ac956a97cb
commit
a38298c5ee
|
@ -50,18 +50,16 @@ class NetworkDialog(QDialog):
|
||||||
else:
|
else:
|
||||||
status = _("Not connected")
|
status = _("Not connected")
|
||||||
|
|
||||||
if interface.is_connected:
|
if network.is_connected():
|
||||||
status += "\n" + _("Main server:") + " %s"%(interface.host)
|
status += "\n" + _("Main server:") + " %s"%(interface.host)
|
||||||
else:
|
else:
|
||||||
status += "\n" + _("Disconnected from main server")
|
status += "\n" + _("Disconnected from main server")
|
||||||
|
|
||||||
|
|
||||||
server = interface.server
|
|
||||||
else:
|
else:
|
||||||
import random
|
import random
|
||||||
status = _("Please choose a server.") + "\n" + _("Select 'Cancel' if you are offline.")
|
status = _("Please choose a server.") + "\n" + _("Select 'Cancel' if you are offline.")
|
||||||
server = interface.server
|
|
||||||
|
|
||||||
|
server = network.default_server
|
||||||
self.servers = network.get_servers()
|
self.servers = network.get_servers()
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,7 +146,7 @@ class NetworkDialog(QDialog):
|
||||||
if not self.config.is_modifiable('proxy'):
|
if not self.config.is_modifiable('proxy'):
|
||||||
for w in [self.proxy_host, self.proxy_port, self.proxy_mode]: w.setEnabled(False)
|
for w in [self.proxy_host, self.proxy_port, self.proxy_mode]: w.setEnabled(False)
|
||||||
|
|
||||||
proxy_config = interface.proxy if interface.proxy else { "mode":"none", "host":"localhost", "port":"8080"}
|
proxy_config = network.proxy if network.proxy else { "mode":"none", "host":"localhost", "port":"8080"}
|
||||||
self.proxy_mode.setCurrentIndex(self.proxy_mode.findText(str(proxy_config.get("mode").upper())))
|
self.proxy_mode.setCurrentIndex(self.proxy_mode.findText(str(proxy_config.get("mode").upper())))
|
||||||
self.proxy_host.setText(proxy_config.get("host"))
|
self.proxy_host.setText(proxy_config.get("host"))
|
||||||
self.proxy_port.setText(proxy_config.get("port"))
|
self.proxy_port.setText(proxy_config.get("port"))
|
||||||
|
|
|
@ -92,7 +92,11 @@ class Blockchain(threading.Thread):
|
||||||
print_error("error", i.server)
|
print_error("error", i.server)
|
||||||
# todo: dismiss that server
|
# todo: dismiss that server
|
||||||
|
|
||||||
h = self.servers_height.get(self.network.interface.server)
|
if self.network.is_connected():
|
||||||
|
h = self.servers_height.get(self.network.interface.server)
|
||||||
|
else:
|
||||||
|
h = None
|
||||||
|
|
||||||
if h is not None and h < height - 1:
|
if h is not None and h < height - 1:
|
||||||
print_error( "Server is lagging", height, h)
|
print_error( "Server is lagging", height, h)
|
||||||
if self.config.get('auto_cycle'):
|
if self.config.get('auto_cycle'):
|
||||||
|
|
|
@ -166,6 +166,11 @@ class Network(threading.Thread):
|
||||||
return self.interface.is_connected
|
return self.interface.is_connected
|
||||||
|
|
||||||
|
|
||||||
|
def wait_until_connected(self):
|
||||||
|
while not self.interface:
|
||||||
|
time.sleep(1)
|
||||||
|
self.interface.connect_event.wait()
|
||||||
|
|
||||||
def set_proxy(self, proxy):
|
def set_proxy(self, proxy):
|
||||||
self.proxy = proxy
|
self.proxy = proxy
|
||||||
|
|
||||||
|
@ -175,7 +180,9 @@ class Network(threading.Thread):
|
||||||
return
|
return
|
||||||
|
|
||||||
# stop the interface in order to terminate subscriptions
|
# stop the interface in order to terminate subscriptions
|
||||||
self.interface.stop()
|
if self.interface:
|
||||||
|
self.interface.stop()
|
||||||
|
|
||||||
# notify gui
|
# notify gui
|
||||||
self.trigger_callback('disconnecting')
|
self.trigger_callback('disconnecting')
|
||||||
# start interface
|
# start interface
|
||||||
|
|
|
@ -1510,12 +1510,12 @@ class WalletSynchronizer(threading.Thread):
|
||||||
self.running = True
|
self.running = True
|
||||||
|
|
||||||
while self.is_running():
|
while self.is_running():
|
||||||
interface = self.network.interface
|
|
||||||
if not interface.is_connected:
|
|
||||||
print_error("synchronizer: waiting for interface")
|
|
||||||
interface.connect_event.wait()
|
|
||||||
|
|
||||||
self.run_interface(interface)
|
if not self.network.is_connected():
|
||||||
|
print_error("synchronizer: waiting for interface")
|
||||||
|
self.network.wait_until_connected()
|
||||||
|
|
||||||
|
self.run_interface(self.network.interface)
|
||||||
|
|
||||||
|
|
||||||
def run_interface(self, interface):
|
def run_interface(self, interface):
|
||||||
|
|
Loading…
Reference in New Issue