command line: wait until daemon is connected
This commit is contained in:
parent
3e6f903da3
commit
2120b1a573
5
electrum
5
electrum
|
@ -113,6 +113,11 @@ def run_command(cmd, password=None, args=None):
|
||||||
s = daemon_socket()
|
s = daemon_socket()
|
||||||
network = NetworkProxy(s, config)
|
network = NetworkProxy(s, config)
|
||||||
network.start()
|
network.start()
|
||||||
|
while network.is_connecting():
|
||||||
|
time.sleep(0.1)
|
||||||
|
if not network.is_connected():
|
||||||
|
print_msg("daemon is not connected")
|
||||||
|
sys.exit(1)
|
||||||
if wallet:
|
if wallet:
|
||||||
wallet.start_threads(network)
|
wallet.start_threads(network)
|
||||||
wallet.update()
|
wallet.update()
|
||||||
|
|
|
@ -125,7 +125,8 @@ class ClientThread(threading.Thread):
|
||||||
try:
|
try:
|
||||||
new_id = self.network.interface.send([(method, params)], cb) [0]
|
new_id = self.network.interface.send([(method, params)], cb) [0]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.queue.put(out = {'id':_id, 'error':str(e)})
|
self.queue.put({'id':_id, 'error':str(e)})
|
||||||
|
print_error("network interface error", str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
self.unanswered_requests[new_id] = _id
|
self.unanswered_requests[new_id] = _id
|
||||||
|
|
|
@ -117,7 +117,7 @@ class Network(threading.Thread):
|
||||||
self.subscriptions[self.on_peers] = [('server.peers.subscribe',[])]
|
self.subscriptions[self.on_peers] = [('server.peers.subscribe',[])]
|
||||||
self.pending_transactions_for_notifications = []
|
self.pending_transactions_for_notifications = []
|
||||||
|
|
||||||
self.connection_status = 'disconnected'
|
self.connection_status = 'connecting'
|
||||||
|
|
||||||
def set_status(self, status):
|
def set_status(self, status):
|
||||||
self.connection_status = status
|
self.connection_status = status
|
||||||
|
|
|
@ -54,7 +54,7 @@ class NetworkProxy(threading.Thread):
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
|
|
||||||
# status variables
|
# status variables
|
||||||
self.status = 'disconnected'
|
self.status = 'connecting'
|
||||||
self.servers = {}
|
self.servers = {}
|
||||||
self.banner = ''
|
self.banner = ''
|
||||||
self.height = 0
|
self.height = 0
|
||||||
|
@ -181,6 +181,9 @@ class NetworkProxy(threading.Thread):
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
return self.status == 'connected'
|
return self.status == 'connected'
|
||||||
|
|
||||||
|
def is_connecting(self):
|
||||||
|
return self.status == 'connecting'
|
||||||
|
|
||||||
def is_up_to_date(self):
|
def is_up_to_date(self):
|
||||||
return self.synchronous_get([('network.is_up_to_date',[])])[0]
|
return self.synchronous_get([('network.is_up_to_date',[])])[0]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue