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.
40 lines
1.1 KiB
Python
Executable File
40 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Subscribe to a pattern on the local DECNET bus and print events.
|
|
|
|
Usage: scripts/bus/sub.py 'topology.>'
|
|
scripts/bus/sub.py 'system.bus.health'
|
|
DECNET_BUS_SOCKET=/tmp/decnet-bus.sock scripts/bus/sub.py 'topology.*.status'
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import os
|
|
import sys
|
|
|
|
from decnet.bus.unix_client import UnixSocketBus
|
|
|
|
|
|
async def main(pattern: str) -> None:
|
|
sock = os.environ.get("DECNET_BUS_SOCKET", "/tmp/decnet-bus.sock")
|
|
client = UnixSocketBus(sock, client_name="scripts-sub")
|
|
await client.connect()
|
|
sub = client.subscribe(pattern)
|
|
print(f"sub: pattern={pattern!r} socket={sock} (Ctrl-C to stop)", flush=True)
|
|
try:
|
|
async with sub:
|
|
async for ev in sub:
|
|
print(f"{ev.topic} type={ev.type!r} payload={ev.payload}", flush=True)
|
|
finally:
|
|
await client.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 2:
|
|
print("Usage: sub.py <pattern>", file=sys.stderr)
|
|
sys.exit(2)
|
|
try:
|
|
asyncio.run(main(sys.argv[1]))
|
|
except KeyboardInterrupt:
|
|
pass
|