From b1273d39003ebb83793c664cf5448f0af07c6f89 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 4 Oct 2013 13:51:46 +0200 Subject: [PATCH] network.is_connected() --- gui/qt/main_window.py | 4 ++-- lib/network.py | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 19f99c2..59e6496 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -531,7 +531,7 @@ class ElectrumWindow(QMainWindow): def update_status(self): - if self.network.interface and self.network.interface.is_connected: + if self.network.is_connected(): if not self.wallet.up_to_date: text = _("Synchronizing...") icon = QIcon(":icons/status_waiting.png") @@ -561,7 +561,7 @@ class ElectrumWindow(QMainWindow): def update_wallet(self): self.update_status() - if self.wallet.up_to_date or not self.network.interface.is_connected: + if self.wallet.up_to_date or not self.network.is_connected(): self.update_history_tab() self.update_receive_tab() self.update_contacts_tab() diff --git a/lib/network.py b/lib/network.py index 1412c46..372809f 100644 --- a/lib/network.py +++ b/lib/network.py @@ -68,6 +68,10 @@ class Network(threading.Thread): self.subscriptions[self.on_peers] = [('server.peers.subscribe',[])] + def is_connected(self): + return self.interface and self.interface.is_connected + + def send_subscriptions(self): for cb, sub in self.subscriptions.items(): self.interface.send(sub, cb) @@ -108,7 +112,11 @@ class Network(threading.Thread): else: choice_list.append(s) - if not choice_list: return + if not choice_list: + if not self.interfaces: + # we are probably offline, retry later + self.disconnected_servers = [] + return server = random.choice( choice_list ) return server -- 1.7.1