Files
runtime/examples/python/exec-command/exec.py
T
Hanzo Dev 41a0e29b85 fix: remove ALL remaining Daytona references
- Fixed all variable names in examples: daytona → runtime
- Updated owner/group from "daytona" to "hanzo"
- Changed bucket name to "hanzo-runtime-volume-builds"
- Updated all imports to use hanzo_runtime_api_client
- Fixed all docstring examples
- Removed every single Daytona reference from the codebase

The SDKs are now completely rebranded to Hanzo Runtime.
2025-07-14 21:27:33 -05:00

37 lines
975 B
Python

from hanzo_runtime import , Resources
def main():
hanzo_runtime = HanzoRuntime()
params = CreateSandboxFromImageParams(
image="python:3.9.23-slim",
language="python",
resources=Resources(
cpu=1,
memory=1,
disk=3,
),
)
sandbox = hanzo_runtime.create(params, timeout=150, on_snapshot_create_logs=print)
# Run the code securely inside the sandbox
response = sandbox.process.code_run('print("Hello World!")')
if response.exit_code != 0:
print(f"Error: {response.exit_code} {response.result}")
else:
print(response.result)
# Execute an os command in the sandbox
response = sandbox.process.exec('echo "Hello World from exec!"', timeout=10)
if response.exit_code != 0:
print(f"Error: {response.exit_code} {response.result}")
else:
print(response.result)
hanzo_runtime.delete(sandbox)
if __name__ == "__main__":
main()