# Excloud Python SDK
[](https://badge.fury.io/py/excloud)
[](https://pypi.org/project/excloud/)
[](https://opensource.org/licenses/MIT)
Python SDK for creating and managing cloud sandboxes with Excloud. Easily spin up isolated computing environments for development, testing, and automation.
## Installation
```bash
pip install excloud
```
## Quick Start
```python
from excloud import Client
# Initialize client with your API key
client = Client(api_key="your_api_key_here")
# Create a sandbox
sandbox = client.create()
print(f"Sandbox created: {sandbox.name}")
# Execute commands in the sandbox
result = sandbox.run("python --version")
print(result)
# Clean up
sandbox.destroy()
```
## Usage with Context Manager
For automatic cleanup, use the context manager:
```python
from excloud import Client
client = Client(api_key="your_api_key")
with client.create() as sandbox:
# Execute commands
result = sandbox.run("ls -la")
print(result)
# Sandbox is automatically destroyed when exiting the context
```
## Features
- **Easy Sandbox Management**: Create, manage, and destroy cloud sandboxes with simple API calls
- **Command Execution**: Run shell commands and scripts in isolated environments
- **Real-time Communication**: WebSocket-based real-time command execution and output streaming
- **Context Manager Support**: Automatic resource cleanup with Python context managers
- **Comprehensive Error Handling**: Detailed exceptions for different failure scenarios
- **Logging Support**: Built-in logging for debugging and monitoring
## API Reference
### Client
```python
from excloud import Client
client = Client(
api_key="your_api_key",
base_url="https://compute.excloud.in", # Optional, defaults to production URL
timeout=10 # Optional, request timeout in seconds
)
```
### Methods
#### `client.create()`
Creates a new sandbox and returns a `Sandbox` instance.
#### `client.get(sandbox_id)`
Retrieves an existing sandbox by ID.
#### `client.list()`
Lists all sandboxes associated with your account.
### Sandbox
#### `sandbox.run(command)`
Executes a command in the sandbox and returns the result.
```python
result = sandbox.run("echo 'Hello, World!'")
print(result) # Output from the command
print(result.exit_code) # Exit code (0 for success)
```
#### `sandbox.upload_file(local_path, remote_path)`
Uploads a file from your local machine to the sandbox.
#### `sandbox.download_file(remote_path, local_path)`
Downloads a file from the sandbox to your local machine.
#### `sandbox.destroy()`
Destroys the sandbox and cleans up all resources.
## Error Handling
The SDK provides specific exceptions for different error scenarios:
```python
from excloud import Client
from excloud import (
AuthenticationError,
SandboxCreationError,
CommandExecutionError,
ConnectionError,
SandboxNotFoundError
)
try:
client = Client(api_key="invalid_key")
sandbox = client.create()
except AuthenticationError:
print("Invalid API key")
except SandboxCreationError:
print("Failed to create sandbox")
except ConnectionError:
print("Network connection failed")
```
## Configuration
### Environment Variables
You can also configure the client using environment variables:
```bash
export EXCLOUD_API_KEY="your_api_key"
export EXCLOUD_BASE_URL="https://compute.excloud.in"
```
```python
import os
from excloud import Client
# Client will automatically use environment variables
client = Client(api_key=os.getenv("EXCLOUD_API_KEY"))
```
## Requirements
- Python 3.7+
- `requests>=2.25.0`
- `websockets>=11.0`
## Examples
### Running a Python Script
```python
from excloud import Client
client = Client(api_key="your_api_key")
with client.create() as sandbox:
# Create a Python script
script = """
import json
data = {"message": "Hello from sandbox!", "status": "success"}
print(json.dumps(data, indent=2))
"""
# Write script to file
sandbox.run(f"cat > script.py << 'EOF'\n{script}\nEOF")
# Execute the script
result = sandbox.run("python script.py")
print(result)
```
### Installing and Using Packages
```python
from excloud import Client
client = Client(api_key="your_api_key")
with client.create() as sandbox:
# Install packages
sandbox.run("pip install numpy pandas")
# Use the packages
result = sandbox.run("python -c 'import numpy as np; print(np.__version__)'")
print(f"NumPy version: {result}")
```
## Support
- **Documentation**: [https://docs.excloud.in](https://docs.excloud.in)
- **Issues**: [GitHub Issues](https://github.com/excloud/excloud-python/issues)
- **Support**: support@excloud.in
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
## Changelog
### 0.1.0
- Initial release
- Basic sandbox creation and management
- Command execution support
- WebSocket-based real-time communication
- Context manager support
Raw data
{
"_id": null,
"home_page": null,
"name": "excloud",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "Excloud <support@excloud.in>",
"keywords": "cloud, sandbox, containers, development, testing, api",
"author": null,
"author_email": "Excloud <support@excloud.in>",
"download_url": "https://files.pythonhosted.org/packages/9c/b2/26ab56367ad2a81f82dbae8a81070f09b295901c54163973f67963271803/excloud-0.1.2.tar.gz",
"platform": null,
"description": "# Excloud Python SDK\n\n[](https://badge.fury.io/py/excloud)\n[](https://pypi.org/project/excloud/)\n[](https://opensource.org/licenses/MIT)\n\nPython SDK for creating and managing cloud sandboxes with Excloud. Easily spin up isolated computing environments for development, testing, and automation.\n\n## Installation\n\n```bash\npip install excloud\n```\n\n## Quick Start\n\n```python\nfrom excloud import Client\n\n# Initialize client with your API key\nclient = Client(api_key=\"your_api_key_here\")\n\n# Create a sandbox\nsandbox = client.create()\nprint(f\"Sandbox created: {sandbox.name}\")\n\n# Execute commands in the sandbox\nresult = sandbox.run(\"python --version\")\nprint(result)\n\n# Clean up\nsandbox.destroy()\n```\n\n## Usage with Context Manager\n\nFor automatic cleanup, use the context manager:\n\n```python\nfrom excloud import Client\n\nclient = Client(api_key=\"your_api_key\")\n\nwith client.create() as sandbox:\n # Execute commands\n result = sandbox.run(\"ls -la\")\n print(result)\n\n# Sandbox is automatically destroyed when exiting the context\n```\n\n## Features\n\n- **Easy Sandbox Management**: Create, manage, and destroy cloud sandboxes with simple API calls\n- **Command Execution**: Run shell commands and scripts in isolated environments\n- **Real-time Communication**: WebSocket-based real-time command execution and output streaming\n- **Context Manager Support**: Automatic resource cleanup with Python context managers\n- **Comprehensive Error Handling**: Detailed exceptions for different failure scenarios\n- **Logging Support**: Built-in logging for debugging and monitoring\n\n## API Reference\n\n### Client\n\n```python\nfrom excloud import Client\n\nclient = Client(\n api_key=\"your_api_key\",\n base_url=\"https://compute.excloud.in\", # Optional, defaults to production URL\n timeout=10 # Optional, request timeout in seconds\n)\n```\n\n### Methods\n\n#### `client.create()`\nCreates a new sandbox and returns a `Sandbox` instance.\n\n#### `client.get(sandbox_id)`\nRetrieves an existing sandbox by ID.\n\n#### `client.list()`\nLists all sandboxes associated with your account.\n\n### Sandbox\n\n#### `sandbox.run(command)`\nExecutes a command in the sandbox and returns the result.\n\n```python\nresult = sandbox.run(\"echo 'Hello, World!'\")\nprint(result) # Output from the command\nprint(result.exit_code) # Exit code (0 for success)\n```\n\n#### `sandbox.upload_file(local_path, remote_path)`\nUploads a file from your local machine to the sandbox.\n\n#### `sandbox.download_file(remote_path, local_path)`\nDownloads a file from the sandbox to your local machine.\n\n#### `sandbox.destroy()`\nDestroys the sandbox and cleans up all resources.\n\n## Error Handling\n\nThe SDK provides specific exceptions for different error scenarios:\n\n```python\nfrom excloud import Client\nfrom excloud import (\n AuthenticationError,\n SandboxCreationError,\n CommandExecutionError,\n ConnectionError,\n SandboxNotFoundError\n)\n\ntry:\n client = Client(api_key=\"invalid_key\")\n sandbox = client.create()\nexcept AuthenticationError:\n print(\"Invalid API key\")\nexcept SandboxCreationError:\n print(\"Failed to create sandbox\")\nexcept ConnectionError:\n print(\"Network connection failed\")\n```\n\n## Configuration\n\n### Environment Variables\n\nYou can also configure the client using environment variables:\n\n```bash\nexport EXCLOUD_API_KEY=\"your_api_key\"\nexport EXCLOUD_BASE_URL=\"https://compute.excloud.in\"\n```\n\n```python\nimport os\nfrom excloud import Client\n\n# Client will automatically use environment variables\nclient = Client(api_key=os.getenv(\"EXCLOUD_API_KEY\"))\n```\n\n## Requirements\n\n- Python 3.7+\n- `requests>=2.25.0`\n- `websockets>=11.0`\n\n## Examples\n\n### Running a Python Script\n\n```python\nfrom excloud import Client\n\nclient = Client(api_key=\"your_api_key\")\n\nwith client.create() as sandbox:\n # Create a Python script\n script = \"\"\"\nimport json\ndata = {\"message\": \"Hello from sandbox!\", \"status\": \"success\"}\nprint(json.dumps(data, indent=2))\n\"\"\"\n\n # Write script to file\n sandbox.run(f\"cat > script.py << 'EOF'\\n{script}\\nEOF\")\n\n # Execute the script\n result = sandbox.run(\"python script.py\")\n print(result)\n```\n\n### Installing and Using Packages\n\n```python\nfrom excloud import Client\n\nclient = Client(api_key=\"your_api_key\")\n\nwith client.create() as sandbox:\n # Install packages\n sandbox.run(\"pip install numpy pandas\")\n\n # Use the packages\n result = sandbox.run(\"python -c 'import numpy as np; print(np.__version__)'\")\n print(f\"NumPy version: {result}\")\n```\n\n## Support\n\n- **Documentation**: [https://docs.excloud.in](https://docs.excloud.in)\n- **Issues**: [GitHub Issues](https://github.com/excloud/excloud-python/issues)\n- **Support**: support@excloud.in\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## Changelog\n\n### 0.1.0\n- Initial release\n- Basic sandbox creation and management\n- Command execution support\n- WebSocket-based real-time communication\n- Context manager support\n",
"bugtrack_url": null,
"license": null,
"summary": "Python SDK for creating and managing cloud sandboxes with Excloud",
"version": "0.1.2",
"project_urls": {
"Bug Tracker": "https://github.com/excloud-in/pythons-sdk/issues",
"Documentation": "https://excloud.in/docs",
"Homepage": "https://excloud.in",
"Repository": "https://github.com/excloud-in/python-sdk"
},
"split_keywords": [
"cloud",
" sandbox",
" containers",
" development",
" testing",
" api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "19d9c239a61eb06e8fedc575e8a11f4c20fc8e7ee06e9322b9eade19c2c78384",
"md5": "959f22cdf3eaaf2aba0e9a8176f7d05f",
"sha256": "79ce20177ece8cfb76dc0e20bcef9f0e5d19a65c2090dabdd519ff8cf57c13ab"
},
"downloads": -1,
"filename": "excloud-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "959f22cdf3eaaf2aba0e9a8176f7d05f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 18804,
"upload_time": "2025-08-13T21:08:21",
"upload_time_iso_8601": "2025-08-13T21:08:21.172296Z",
"url": "https://files.pythonhosted.org/packages/19/d9/c239a61eb06e8fedc575e8a11f4c20fc8e7ee06e9322b9eade19c2c78384/excloud-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9cb226ab56367ad2a81f82dbae8a81070f09b295901c54163973f67963271803",
"md5": "73ff71f9c883b87b94b2f25ec60d4358",
"sha256": "a7b76d1352d65d522d3db4f72e6a4c4a3322d8da47f9d722c07f82baab11849f"
},
"downloads": -1,
"filename": "excloud-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "73ff71f9c883b87b94b2f25ec60d4358",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 21522,
"upload_time": "2025-08-13T21:08:22",
"upload_time_iso_8601": "2025-08-13T21:08:22.841890Z",
"url": "https://files.pythonhosted.org/packages/9c/b2/26ab56367ad2a81f82dbae8a81070f09b295901c54163973f67963271803/excloud-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-13 21:08:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "excloud-in",
"github_project": "pythons-sdk",
"github_not_found": true,
"lcname": "excloud"
}