Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check_operation_status script #4

Merged
merged 11 commits into from
Dec 11, 2023
46 changes: 46 additions & 0 deletions scitt/check_operation_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
""" Module for checking when a statement has been anchored in the append-only ledger """

import json
import subprocess
import argparse
import time


def check_operation_id(
operation_id: str
)-> str:

return subprocess.check_output("curl -s -H @$HOME/.datatrails/bearer-token.txt https://app.datatrails.ai/archivist/v1/publicscitt/operations/"+operation_id, shell = True).decode()


def main():
"""Creates a signed statement"""

parser = argparse.ArgumentParser(description="Create a signed statement.")

# signing key file
parser.add_argument(
"--operation-id",
type=str,
help="the operation-id from a registered statement",
)

args = parser.parse_args()

# Check the operation status until the status=succeeded
while True:
retval=check_operation_id(args.operation_id)
if retval=="Jwt is expired":
print(retval)
return

response = json.loads(check_operation_id(args.operation_id))
if "status" in response and response["status"] == "succeeded":
print(response["entryID"])
break
else:
time.sleep(1)


if __name__ == "__main__":
main()