electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 94c6a1f6cf00f7587eb65d91c322adebd6ca0454
parent ee396a063303a341c6615904561b8ac2b4531797
Author: thomasv <thomasv@gitorious>
Date:   Wed,  8 Feb 2012 14:13:11 +0100

display more accurate error messages

Diffstat:
Mclient/gui.py | 13++++++++-----
Mclient/interface.py | 10++++++++--
2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/client/gui.py b/client/gui.py @@ -1128,16 +1128,19 @@ class BitcoinGUI: if self.funds_error: text = "Not enough funds" elif self.wallet.interface.is_connected: - if self.wallet.interface.blocks > 0: + self.network_button.set_tooltip_text("Connected to %s.\n%d blocks\nresponse time: %f"%(self.wallet.interface.host, self.wallet.interface.blocks, self.wallet.interface.rtime)) + if self.wallet.interface.blocks == 0: + self.status_image.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) + text = "Server not ready" + elif not self.wallet.interface.was_polled: + self.status_image.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) + text = "Synchronizing..." + else: self.status_image.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) self.network_button.set_tooltip_text("Connected to %s.\n%d blocks\nresponse time: %f"%(self.wallet.interface.host, self.wallet.interface.blocks, self.wallet.interface.rtime)) c, u = self.wallet.get_balance() text = "Balance: %s "%( format_satoshis(c) ) if u: text += "[%s unconfirmed]"%( format_satoshis(u,True) ) - else: - self.status_image.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) - self.network_button.set_tooltip_text("Connected to %s.\n%d blocks\nresponse time: %f"%(self.wallet.interface.host, self.wallet.interface.blocks, self.wallet.interface.rtime)) - text = "Server not ready" else: self.status_image.set_from_stock(gtk.STOCK_NO, gtk.ICON_SIZE_MENU) self.network_button.set_tooltip_text("Trying to contact %s.\n%d blocks"%(self.wallet.interface.host, self.wallet.interface.blocks)) diff --git a/client/interface.py b/client/interface.py @@ -33,6 +33,7 @@ class Interface: self.set_port(50000) self.is_connected = False self.was_updated = True # fixme: use a semaphore + self.was_polled = False # True after the first poll def set_port(self, port_number): self.port = port_number @@ -102,12 +103,14 @@ class Interface: blocks, changed_addr = ast.literal_eval( out ) if blocks == -1: raise BaseException("session not found") self.blocks = int(blocks) + if changed_addr: self.was_updated = True + self.was_polled = True return changed_addr def new_session(self, addresses, version): + self.was_polled = False out = self.handler('session.new', [ version, addresses ] ) self.session_id, self.message = ast.literal_eval( out ) - self.was_updated = True def update_session(self, addresses): out = self.handler('session.update', [ self.session_id, addresses ] ) @@ -144,6 +147,10 @@ class Interface: self.is_connected = False self.new_session(wallet.all_addresses(), wallet.electrum_version) self.update_session = False + except socket.error: + print "Not connected" + time.sleep(self.poll_interval()) + continue except: traceback.print_exc(file=sys.stdout) time.sleep(self.poll_interval()) @@ -163,7 +170,6 @@ class Interface: # define a method to update the list if self.update_wallet(wallet): self.update_session( wallet.all_addresses() ) - self.was_updated = True # for gui time.sleep(self.poll_interval()) except BaseException: