Updated scripts

This commit is contained in:
Alexander Demidko 2018-06-25 17:16:14 +03:00
parent d0118420aa
commit 5444d00bb7
5 changed files with 9 additions and 13 deletions

0
cli/block_report.py Normal file → Executable file
View File

0
cli/common_parse_utils.py Normal file → Executable file
View File

0
cli/parse_chain.py Normal file → Executable file
View File

22
cli/query.py Normal file → Executable file
View File

@ -1,13 +1,13 @@
#!/usr/bin/python
#!/usr/bin/python2.7
import sys, urllib, json, datetime, time, hashlib, sha3
from common_parse_utils import read_json, get_sync_info, get_max_height
CMD_FAST_PUT = "fastput"
CMD_PUT = "put"
CMD_RUN = "run"
CMD_PUT_TX = "put"
CMD_GET_QUERY = "get"
CMD_LS_QUERY = "ls"
ALL_COMMANDS = {CMD_GET_QUERY, CMD_PUT, CMD_RUN, CMD_FAST_PUT, CMD_LS_QUERY}
ALL_COMMANDS = {CMD_RUN, CMD_PUT_TX, CMD_GET_QUERY, CMD_LS_QUERY}
def verify_merkle_proof(result, proof, app_hash):
parts = proof.split(", ")
@ -51,10 +51,8 @@ def print_checked_abci_query(tmaddress, height, command, query, tentative_info):
print_response("height", height)
print_response("app_hash", app_hash or "NOT_READY")
print_response("proof", (proof or "NO_PROOF").upper())
print_response("result", result or "EMPTY", True)
if success:
print "OK"
else:
print result or "???"
if not success:
print_response("bad", message, True)
def latest_provable_height(tmaddress):
@ -68,7 +66,6 @@ def wait_for_height(tmaddress, height, seconds_to_wait = 5):
time.sleep(wait_step)
num_args = len(sys.argv)
if num_args < 4 or not sys.argv[2] in ALL_COMMANDS:
print "usage: python query.py host:port <command> [flags] arg"
@ -79,7 +76,7 @@ tmaddress = sys.argv[1]
command = sys.argv[2]
flags = "".join(sys.argv[3:(num_args - 1)])
arg = sys.argv[num_args - 1]
if command in {CMD_FAST_PUT, CMD_PUT, CMD_RUN}:
if command in {CMD_PUT_TX, CMD_RUN}:
if command == CMD_RUN:
query_key = "optarg"
tx = query_key + "=" + arg
@ -96,13 +93,12 @@ if command in {CMD_FAST_PUT, CMD_PUT, CMD_RUN}:
print_response("bad", log or "NO_MESSAGE", True)
else:
info = response["result"].get("deliver_tx", {}).get("info")
if command in {CMD_PUT, CMD_RUN} and info is not None:
if command in {CMD_RUN} and info is not None:
wait_for_height(tmaddress, height + 1)
print_checked_abci_query(tmaddress, height, "get", query_key, info)
else:
print_response("height", height)
print_response("info", info or "EMPTY")
print "OK"
elif command in {CMD_GET_QUERY, CMD_LS_QUERY}:
height = latest_provable_height(tmaddress)
print_checked_abci_query(tmaddress, height, command, arg, None)
print_checked_abci_query(tmaddress, height, command, arg, None)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB