Replaces LICENSE (GPLv3 -> AGPLv3) and prepends `SPDX-License-Identifier: AGPL-3.0-or-later` to every source file across decnet/, decnet_web/, tests/, scripts/, and tools/. Rationale: closes the GPLv3 ASP loophole so any party operating a modified DECNET as a network service must offer their modified source. Personal copyright (Samuel Paschuan) + inbound=outbound contributions make a future unilateral relicense infeasible. - LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt) - COPYRIGHT: project copyright notice - tools/add_spdx_headers.py: idempotent header injector (shebang- and PEP 263-aware) Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh). No behavior change; comments only.
46 lines
1.5 KiB
Python
Executable File
46 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Publish a single event to the local DECNET bus.
|
|
|
|
Usage: scripts/bus/pub.py <topic> [json-payload] [--type EVENT_TYPE]
|
|
Examples:
|
|
scripts/bus/pub.py topology.abc.status '{"state": "active"}'
|
|
scripts/bus/pub.py topology.abc.mutation.applied '{"id": 1}' --type applied
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import asyncio
|
|
import json
|
|
import os
|
|
|
|
from decnet.bus.unix_client import UnixSocketBus
|
|
|
|
|
|
async def main(topic: str, payload: dict, event_type: str) -> None:
|
|
sock = os.environ.get("DECNET_BUS_SOCKET", "/tmp/decnet-bus.sock")
|
|
client = UnixSocketBus(sock, client_name="scripts-pub")
|
|
await client.connect()
|
|
try:
|
|
await client.publish(topic, payload, event_type=event_type)
|
|
print(f"pub: {topic} type={event_type!r} payload={payload}")
|
|
finally:
|
|
await client.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("topic")
|
|
ap.add_argument("payload", nargs="?", default="{}", help="JSON object (default {})")
|
|
ap.add_argument("--type", dest="event_type", default="", help="optional event_type tag")
|
|
args = ap.parse_args()
|
|
|
|
try:
|
|
payload = json.loads(args.payload)
|
|
except json.JSONDecodeError as exc:
|
|
raise SystemExit(f"pub: payload is not valid JSON: {exc}")
|
|
if not isinstance(payload, dict):
|
|
raise SystemExit("pub: payload must be a JSON object")
|
|
|
|
asyncio.run(main(args.topic, payload, args.event_type))
|