Skip to main content

Python SDK for the Sprites API

Project description

Sprites Python SDK

Python SDK for Sprites - remote command execution platform.

Installation

pip install sprites-py

Quick Start

from sprites import SpritesClient

# Create a client
client = SpritesClient(token="your-token")

# Get a sprite handle
sprite = client.sprite("my-sprite")

# Run a command
result = sprite.run("echo", "hello", capture_output=True)
print(result.stdout.decode())  # "hello\n"

# Or use the Go-style API
cmd = sprite.command("ls", "-la")
output = cmd.output()
print(output.decode())

API Overview

SpritesClient

from sprites import SpritesClient

client = SpritesClient(
    token="your-token",
    base_url="https://api.sprites.dev",  # optional
    timeout=30.0,  # optional
)

# Create a sprite
sprite = client.create_sprite("my-sprite")

# Get a sprite handle (doesn't create it)
sprite = client.sprite("my-sprite")

# Delete a sprite
client.delete_sprite("my-sprite")

Sprite

# Run a command (subprocess.run style)
result = sprite.run("echo", "hello", capture_output=True, timeout=30)
print(result.returncode)
print(result.stdout)

# Create a command (Go exec.Cmd style)
cmd = sprite.command("bash", "-c", "echo hello")
output = cmd.output()  # Returns stdout
combined = cmd.combined_output()  # Returns stdout + stderr

# TTY mode
cmd = sprite.command("bash", tty=True, tty_rows=24, tty_cols=80)
cmd.run()

Checkpoints

# List checkpoints
checkpoints = sprite.list_checkpoints()

# Create a checkpoint
stream = sprite.create_checkpoint("my checkpoint")
for msg in stream:
    print(msg.type, msg.data)

# Restore a checkpoint
stream = sprite.restore_checkpoint("checkpoint-id")
for msg in stream:
    print(msg.type, msg.data)

Network Policy

from sprites.types import NetworkPolicy, PolicyRule

# Get current policy
policy = sprite.get_network_policy()

# Update policy
new_policy = NetworkPolicy(rules=[
    PolicyRule(domain="example.com", action="allow"),
])
sprite.update_network_policy(new_policy)

Requirements

  • Python 3.11+
  • websockets
  • httpx

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sprites_py-0.0.1a1.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sprites_py-0.0.1a1-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file sprites_py-0.0.1a1.tar.gz.

File metadata

  • Download URL: sprites_py-0.0.1a1.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sprites_py-0.0.1a1.tar.gz
Algorithm Hash digest
SHA256 b90168a1eaf98d8d550b2d9b674067e388e3b6c2db5bc4ccfa457f4922c04d73
MD5 441a872be05b943fb220f383aa0e727e
BLAKE2b-256 0b6c6bace1ef983c6bb3466416030a88e465d4170522bca5fe9f24709cd99ec1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sprites_py-0.0.1a1.tar.gz:

Publisher: publish.yml on superfly/sprites-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sprites_py-0.0.1a1-py3-none-any.whl.

File metadata

  • Download URL: sprites_py-0.0.1a1-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sprites_py-0.0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 9568ee1001d1b489985413aed1041f0aa4dbf433b8194eb540aa16e6867a96ac
MD5 5fdc4d207562e4041f05c5969924c12f
BLAKE2b-256 674736e48387e976529e2c92663c3912c3d658f973009dc4a1bf19309ffd441a

See more details on using hashes here.

Provenance

The following attestation bundles were made for sprites_py-0.0.1a1-py3-none-any.whl:

Publisher: publish.yml on superfly/sprites-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page