Improved rnx interactive mode

This commit is contained in:
Mark Qvist 2022-07-02 10:38:35 +02:00
parent 2335a71427
commit 4a725de935

View File

@ -337,13 +337,15 @@ def execute(configdir, identitypath = None, verbosity = 0, quietness = 0, detail
if link == None or link.status == RNS.Link.CLOSED or link.status == RNS.Link.PENDING: if link == None or link.status == RNS.Link.CLOSED or link.status == RNS.Link.PENDING:
link = RNS.Link(listener_destination) link = RNS.Link(listener_destination)
link.did_identify = False
if not spin(until=lambda: link.status == RNS.Link.ACTIVE, msg="Establishing link with "+RNS.prettyhexrep(destination_hash), timeout=timeout): if not spin(until=lambda: link.status == RNS.Link.ACTIVE, msg="Establishing link with "+RNS.prettyhexrep(destination_hash), timeout=timeout):
print("Could not establish link with "+RNS.prettyhexrep(destination_hash)) print("Could not establish link with "+RNS.prettyhexrep(destination_hash))
exit(243) exit(243)
if not noid: if not noid and not link.did_identify:
link.identify(identity) link.identify(identity)
link.did_identify = True
if stdin != None: if stdin != None:
stdin = stdin.encode("utf-8") stdin = stdin.encode("utf-8")
@ -380,6 +382,9 @@ def execute(configdir, identitypath = None, verbosity = 0, quietness = 0, detail
if request_receipt.status == RNS.RequestReceipt.FAILED: if request_receipt.status == RNS.RequestReceipt.FAILED:
print("Could not request remote execution") print("Could not request remote execution")
if interactive:
return
else:
exit(244) exit(244)
spin( spin(
@ -390,6 +395,9 @@ def execute(configdir, identitypath = None, verbosity = 0, quietness = 0, detail
if request_receipt.status == RNS.RequestReceipt.FAILED: if request_receipt.status == RNS.RequestReceipt.FAILED:
print("No result was received") print("No result was received")
if interactive:
return
else:
exit(245) exit(245)
spin_stat( spin_stat(
@ -399,6 +407,9 @@ def execute(configdir, identitypath = None, verbosity = 0, quietness = 0, detail
if request_receipt.status == RNS.RequestReceipt.FAILED: if request_receipt.status == RNS.RequestReceipt.FAILED:
print("Receiving result failed") print("Receiving result failed")
if interactive:
return
else:
exit(246) exit(246)
if request_receipt.response != None: if request_receipt.response != None:
@ -414,6 +425,9 @@ def execute(configdir, identitypath = None, verbosity = 0, quietness = 0, detail
except Exception as e: except Exception as e:
print("Received invalid result") print("Received invalid result")
if interactive:
return
else:
exit(247) exit(247)
if executed: if executed:
@ -484,6 +498,9 @@ def execute(configdir, identitypath = None, verbosity = 0, quietness = 0, detail
exit(248) exit(248)
else: else:
print("No response") print("No response")
if interactive:
return
else:
exit(249) exit(249)
try: try: