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.1rc37.tar.gz (35.2 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.1rc37-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sprites_py-0.0.1rc37.tar.gz
  • Upload date:
  • Size: 35.2 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.1rc37.tar.gz
Algorithm Hash digest
SHA256 2fc58aa80a9a99c1a12cb17725d13675d5e25dc2a33f245f21486473aede05b9
MD5 71d0e1fbd2e6f95d082fa51dd761b1ac
BLAKE2b-256 88cd24bbca8438fdc8a89e3365b927b20f511e1c4529a8574ea252e967f8071c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sprites_py-0.0.1rc37.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.1rc37-py3-none-any.whl.

File metadata

  • Download URL: sprites_py-0.0.1rc37-py3-none-any.whl
  • Upload date:
  • Size: 39.4 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.1rc37-py3-none-any.whl
Algorithm Hash digest
SHA256 d032b0059e2881b16a35349c0f01adafa99143671103a43a79d7e39a0c1ef6c9
MD5 7d67a23d4cc442976efffd6f23c59056
BLAKE2b-256 b68b87c87887ae3bde72425134efea163fdbdef610765a8db7244c7b4adeab46

See more details on using hashes here.

Provenance

The following attestation bundles were made for sprites_py-0.0.1rc37-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