MCPcopy Create free account
hub / github.com/attermann/microReticulum / on_resource_concluded

Function on_resource_concluded

test_interop/python_resource_receiver.py:49–67  ·  view source on GitHub ↗
(resource)

Source from the content-addressed store, hash-verified

47
48
49def on_resource_concluded(resource):
50 if resource.status == RNS.Resource.COMPLETE:
51 # Resource.data may be a file-handle or bytes depending on size.
52 if hasattr(resource.data, "read"):
53 try:
54 resource.data.seek(0)
55 except Exception:
56 pass
57 data = resource.data.read()
58 else:
59 data = bytes(resource.data) if resource.data is not None else b""
60 state["payload_bytes"] = data
61 state["payload_hash"] = hashlib.sha256(data).hexdigest()
62 state["received"] = True
63 print(f"[python] resource complete: {len(data)} bytes, sha256 {state['payload_hash']}",
64 flush=True)
65 else:
66 print(f"[python] resource failed with status {resource.status}", flush=True)
67 state["received"] = True # break the wait loop
68
69
70def on_link_established(link):

Callers

nothing calls this directly

Calls 1

sha256Method · 0.80

Tested by

no test coverage detected