uns-kit 0.0.2__tar.gz → 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {uns_kit-0.0.2 → uns_kit-0.0.4}/PKG-INFO +13 -5
- {uns_kit-0.0.2 → uns_kit-0.0.4}/README.md +12 -4
- {uns_kit-0.0.2 → uns_kit-0.0.4}/pyproject.toml +2 -2
- {uns_kit-0.0.2 → uns_kit-0.0.4}/src/uns_kit/cli.py +19 -0
- uns_kit-0.0.4/src/uns_kit/templates/default/README.md +10 -0
- uns_kit-0.0.4/src/uns_kit/templates/default/pyproject.toml +17 -0
- uns_kit-0.0.4/src/uns_kit/templates/default/src/main.py +27 -0
- {uns_kit-0.0.2 → uns_kit-0.0.4}/src/uns_kit/__init__.py +0 -0
- {uns_kit-0.0.2 → uns_kit-0.0.4}/src/uns_kit/client.py +0 -0
- {uns_kit-0.0.2 → uns_kit-0.0.4}/src/uns_kit/config.py +0 -0
- {uns_kit-0.0.2 → uns_kit-0.0.4}/src/uns_kit/packet.py +0 -0
- {uns_kit-0.0.2 → uns_kit-0.0.4}/src/uns_kit/topic_builder.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uns-kit
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: Lightweight Python UNS MQTT client (pub/sub + infra topics)
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Aljoša Vister
|
|
@@ -32,11 +32,11 @@ poetry install
|
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## CLI
|
|
35
|
-
After `poetry install`,
|
|
35
|
+
After `poetry install`, an `uns-kit-py` command is available (renamed to avoid clashing with the Node CLI):
|
|
36
36
|
```bash
|
|
37
|
-
poetry run uns-kit publish --host localhost:1883 --topic raw/data/ --value 1
|
|
38
|
-
poetry run uns-kit subscribe --host localhost:1883 --topic 'uns-infra/#'
|
|
39
|
-
poetry run uns-kit write-config --path config.json
|
|
37
|
+
poetry run uns-kit-py publish --host localhost:1883 --topic raw/data/ --value 1
|
|
38
|
+
poetry run uns-kit-py subscribe --host localhost:1883 --topic 'uns-infra/#'
|
|
39
|
+
poetry run uns-kit-py write-config --path config.json
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Quick start
|
|
@@ -70,6 +70,14 @@ async for msg in client.resilient_messages("uns-infra/#"):
|
|
|
70
70
|
- `examples/publish.py` — publish 5 data packets.
|
|
71
71
|
- `examples/subscribe.py` — resilient subscription with auto-reconnect.
|
|
72
72
|
|
|
73
|
+
### Create a new project
|
|
74
|
+
```bash
|
|
75
|
+
uns-kit-py create my-uns-py-app
|
|
76
|
+
cd my-uns-py-app
|
|
77
|
+
poetry install
|
|
78
|
+
poetry run python src/main.py
|
|
79
|
+
```
|
|
80
|
+
|
|
73
81
|
## Notes
|
|
74
82
|
- Default QoS is 0; will message is retained on `<statusTopic>alive`.
|
|
75
83
|
- Uptime is published every 10 seconds on `<statusTopic>uptime`.
|
|
@@ -13,11 +13,11 @@ poetry install
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## CLI
|
|
16
|
-
After `poetry install`,
|
|
16
|
+
After `poetry install`, an `uns-kit-py` command is available (renamed to avoid clashing with the Node CLI):
|
|
17
17
|
```bash
|
|
18
|
-
poetry run uns-kit publish --host localhost:1883 --topic raw/data/ --value 1
|
|
19
|
-
poetry run uns-kit subscribe --host localhost:1883 --topic 'uns-infra/#'
|
|
20
|
-
poetry run uns-kit write-config --path config.json
|
|
18
|
+
poetry run uns-kit-py publish --host localhost:1883 --topic raw/data/ --value 1
|
|
19
|
+
poetry run uns-kit-py subscribe --host localhost:1883 --topic 'uns-infra/#'
|
|
20
|
+
poetry run uns-kit-py write-config --path config.json
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Quick start
|
|
@@ -51,6 +51,14 @@ async for msg in client.resilient_messages("uns-infra/#"):
|
|
|
51
51
|
- `examples/publish.py` — publish 5 data packets.
|
|
52
52
|
- `examples/subscribe.py` — resilient subscription with auto-reconnect.
|
|
53
53
|
|
|
54
|
+
### Create a new project
|
|
55
|
+
```bash
|
|
56
|
+
uns-kit-py create my-uns-py-app
|
|
57
|
+
cd my-uns-py-app
|
|
58
|
+
poetry install
|
|
59
|
+
poetry run python src/main.py
|
|
60
|
+
```
|
|
61
|
+
|
|
54
62
|
## Notes
|
|
55
63
|
- Default QoS is 0; will message is retained on `<statusTopic>alive`.
|
|
56
64
|
- Uptime is published every 10 seconds on `<statusTopic>uptime`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "uns-kit"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.4"
|
|
4
4
|
description = "Lightweight Python UNS MQTT client (pub/sub + infra topics)"
|
|
5
5
|
authors = ["Aljoša Vister <aljosa.vister@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -19,7 +19,7 @@ ruff = "^0.6.9"
|
|
|
19
19
|
mypy = "^1.11.2"
|
|
20
20
|
|
|
21
21
|
[tool.poetry.scripts]
|
|
22
|
-
uns-kit = "uns_kit.cli:main"
|
|
22
|
+
uns-kit-py = "uns_kit.cli:main"
|
|
23
23
|
|
|
24
24
|
[build-system]
|
|
25
25
|
requires = ["poetry-core"]
|
|
@@ -2,6 +2,9 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import json
|
|
5
|
+
import os
|
|
6
|
+
import shutil
|
|
7
|
+
import importlib.resources
|
|
5
8
|
from pathlib import Path
|
|
6
9
|
from typing import Optional
|
|
7
10
|
|
|
@@ -120,6 +123,22 @@ async def _run_subscribe(
|
|
|
120
123
|
print(f"{msg.topic} <binary {len(msg.payload)} bytes>")
|
|
121
124
|
|
|
122
125
|
|
|
126
|
+
@cli.command("create", help="Create a new UNS Python app (default template).")
|
|
127
|
+
@click.argument("dest")
|
|
128
|
+
def create(dest: str):
|
|
129
|
+
template_root = importlib.resources.files("uns_kit").joinpath("templates/default")
|
|
130
|
+
dest_path = os.path.abspath(dest)
|
|
131
|
+
if os.path.exists(dest_path):
|
|
132
|
+
raise click.ClickException(f"Destination already exists: {dest_path}")
|
|
133
|
+
shutil.copytree(template_root, dest_path)
|
|
134
|
+
click.echo(f"Created UNS Python app at {dest_path}")
|
|
135
|
+
click.echo("Next steps:")
|
|
136
|
+
click.echo(f" 1) cd {dest_path}")
|
|
137
|
+
click.echo(" 2) poetry install")
|
|
138
|
+
click.echo(" 3) poetry run python src/main.py")
|
|
139
|
+
click.echo(" 4) Edit config.json with your MQTT host/credentials")
|
|
140
|
+
|
|
141
|
+
|
|
123
142
|
@cli.command("write-config", help="Write a minimal config.json scaffold.")
|
|
124
143
|
@click.option("--path", default="config.json", show_default=True)
|
|
125
144
|
def write_config(path: str):
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "uns-py-app"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Example UNS Python application"
|
|
5
|
+
authors = ["Your Name <you@example.com>"]
|
|
6
|
+
package-mode = false
|
|
7
|
+
|
|
8
|
+
[tool.poetry.dependencies]
|
|
9
|
+
python = "^3.10"
|
|
10
|
+
uns-kit = "*"
|
|
11
|
+
|
|
12
|
+
[tool.poetry.group.dev.dependencies]
|
|
13
|
+
pytest = "^8.3.3"
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["poetry-core"]
|
|
17
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from uns_kit import UnsMqttClient, TopicBuilder, UnsPacket
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
async def main():
|
|
8
|
+
cfg = json.loads(Path("config.json").read_text())
|
|
9
|
+
tb = TopicBuilder(cfg["packageName"], cfg["packageVersion"], cfg["processName"])
|
|
10
|
+
client = UnsMqttClient(
|
|
11
|
+
cfg["host"],
|
|
12
|
+
port=cfg.get("port"),
|
|
13
|
+
username=cfg.get("username") or None,
|
|
14
|
+
password=cfg.get("password") or None,
|
|
15
|
+
tls=cfg.get("tls", False),
|
|
16
|
+
client_id=cfg.get("clientId"),
|
|
17
|
+
topic_builder=tb,
|
|
18
|
+
reconnect_interval=1,
|
|
19
|
+
)
|
|
20
|
+
await client.connect()
|
|
21
|
+
await client.publish_packet("raw/data/", UnsPacket.data(value=1, uom="count"))
|
|
22
|
+
async for msg in client.resilient_messages("uns-infra/#"):
|
|
23
|
+
print(msg.topic, msg.payload.decode())
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if __name__ == "__main__":
|
|
27
|
+
asyncio.run(main())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|