from gravixlayer import GravixLayer
client = GravixLayer()
sandbox = client.runtime.create()
result = sandbox.run_cmd(
command="sh -lc 'echo hello; sleep 1; echo world'",
on_stdout=lambda chunk: print(chunk, end="", flush=True),
on_stderr=lambda chunk: print(chunk, end="", flush=True),
)
print(result.exit_code)
for event in sandbox.stream_cmd(command="sh -lc 'echo one; echo two'"):
if event["type"] == "stdout":
print(event["data"], end="", flush=True)
elif event["type"] == "end":
print(event["exit_code"])
sandbox.kill()