Skip to main content

Build and drive CAR-TER layouts from Python — the control docs are the library.

Project description

carterkit

PyPI Downloads Python versions

Build and drive CAR-TER layouts from Python.

The control docs are the library. Every control's schema, fields, and examples are parsed at runtime from the ControlDocs markdown bundled inside the package — the exact same docs the CAR-TER app renders — so the catalog never drifts from the definitions.

pip install carterkit

Explore the controls (zero config)

import carterkit

carterkit.controls()            # {type: schema} for every placeable control
carterkit.doc("gauge")          # full parsed doc: fields, themeFields, examples
print(carterkit.doc_markdown("gauge"))   # the rendered documentation prose
carterkit.examples("button")    # documented example snippets

Build a layout

from carterkit import LayoutBuffer, validate_layout

b = LayoutBuffer.blank(name="Dashboard", columns=4, rows=4)
b.add_control({"type": "gauge", "id": "cpu", "label": "CPU", "min": 0, "max": 100},
              default_span=[2, 2])
b.add_control({"type": "button", "id": "refresh", "label": "Refresh"})

layout = b.layout
findings = validate_layout(layout)      # schema + grid lint against the bundled catalog
print(carterkit.format_findings(findings))

infer.build_layout(payload) generates a wired layout from a sample telemetry dict; codegen.generate_service_stub(layout) emits a runnable MeshSocket server skeleton; theming.theme_for(...) and tune.tune_gauge(...) round out the authoring tools.

Drive a device

import asyncio
from carterkit import CarterClient

async def main():
    c = CarterClient(gateway_url="ws://localhost:18080", token="<mesh token>",
                     channel="home", role="device", name="my-hub")
    c.on("toggle", lambda d: {"ok": True, **d})
    await c.connect()
    await c.broadcast("reading", {"temp_c": 21.4})
    await asyncio.sleep(60)
    await c.close()

asyncio.run(main())

End-to-end encryption (ChaCha20-Poly1305 + per-session salt) is transparent when you pass an e2ee_key. Send a push to every device on a Connect+ account with CarterClient.notify(...) or the stdlib-only carterkit.notify_http(...).

Built on

meshsocket — the WebSocket mesh transport.

The ControlDocs are vendored from the CAR-TER app repo; refresh them with scripts/sync-controldocs.sh.

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

carterkit-0.1.0.tar.gz (68.6 kB view details)

Uploaded Source

Built Distribution

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

carterkit-0.1.0-py3-none-any.whl (89.6 kB view details)

Uploaded Python 3

File details

Details for the file carterkit-0.1.0.tar.gz.

File metadata

  • Download URL: carterkit-0.1.0.tar.gz
  • Upload date:
  • Size: 68.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for carterkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 64004332a448172c210303e794985bd0cff7e9b0d40d7a34d4037cf3eea4fd3b
MD5 93cc3eed635657a39e97fb4ea61c2414
BLAKE2b-256 faecb089f719573a2efa3cb9ece90f04f09f2a4b891b2d15f734429bae229a6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for carterkit-0.1.0.tar.gz:

Publisher: publish.yml on Mariner10/carterkit

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

File details

Details for the file carterkit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: carterkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 89.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for carterkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6de9552456d150b218e0bfb3dcf82c41abe1a59f0fab02a5ecb82d8216e2111a
MD5 b2e4ce61f89bf57faa336637361ecaa5
BLAKE2b-256 90bd5beb8930f3f36fe612e13cd8eae2fefd2c02a87e6a5d3da98e01cc91d5ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for carterkit-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Mariner10/carterkit

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