mirror of
https://github.com/markqvist/LXMF.git
synced 2025-07-31 10:59:01 -04:00
Status query return code
This commit is contained in:
parent
cec903a4dc
commit
26a10cce8f
1 changed files with 10 additions and 4 deletions
|
@ -422,8 +422,8 @@ def query_status(identity, timeout=5, exit_on_fail=False):
|
||||||
timeout = time.time()+timeout
|
timeout = time.time()+timeout
|
||||||
def check_timeout():
|
def check_timeout():
|
||||||
if time.time() > timeout:
|
if time.time() > timeout:
|
||||||
RNS.log("Getting lxmd statistics timed out, exiting now", RNS.LOG_ERROR)
|
|
||||||
if exit_on_fail:
|
if exit_on_fail:
|
||||||
|
RNS.log("Getting lxmd statistics timed out, exiting now", RNS.LOG_ERROR)
|
||||||
exit(200)
|
exit(200)
|
||||||
else:
|
else:
|
||||||
return LXMF.LXMPeer.LXMPeer.ERROR_TIMEOUT
|
return LXMF.LXMPeer.LXMPeer.ERROR_TIMEOUT
|
||||||
|
@ -433,16 +433,22 @@ def query_status(identity, timeout=5, exit_on_fail=False):
|
||||||
if not RNS.Transport.has_path(control_destination.hash):
|
if not RNS.Transport.has_path(control_destination.hash):
|
||||||
RNS.Transport.request_path(control_destination.hash)
|
RNS.Transport.request_path(control_destination.hash)
|
||||||
while not RNS.Transport.has_path(control_destination.hash):
|
while not RNS.Transport.has_path(control_destination.hash):
|
||||||
check_timeout()
|
tc = check_timeout()
|
||||||
|
if tc:
|
||||||
|
return tc
|
||||||
|
|
||||||
link = RNS.Link(control_destination)
|
link = RNS.Link(control_destination)
|
||||||
while not link.status == RNS.Link.ACTIVE:
|
while not link.status == RNS.Link.ACTIVE:
|
||||||
check_timeout()
|
tc = check_timeout()
|
||||||
|
if tc:
|
||||||
|
return tc
|
||||||
|
|
||||||
link.identify(identity)
|
link.identify(identity)
|
||||||
request_receipt = link.request(LXMF.LXMRouter.STATS_GET_PATH, data=None, response_callback=None, failed_callback=None)
|
request_receipt = link.request(LXMF.LXMRouter.STATS_GET_PATH, data=None, response_callback=None, failed_callback=None)
|
||||||
while not request_receipt.get_status() == RNS.RequestReceipt.READY:
|
while not request_receipt.get_status() == RNS.RequestReceipt.READY:
|
||||||
check_timeout()
|
tc = check_timeout()
|
||||||
|
if tc:
|
||||||
|
return tc
|
||||||
|
|
||||||
return request_receipt.get_response()
|
return request_receipt.get_response()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue