uns-kit 0.0.6__py3-none-any.whl → 0.0.7__py3-none-any.whl
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/cli.py +12 -1
- uns_kit/templates/default/main.py +34 -0
- uns_kit/templates/default/pyproject.toml +1 -1
- uns_kit/templates/default/runtime.json +4 -0
- uns_kit/templates/default/uns_py_app/__init__.py +1 -0
- {uns_kit-0.0.6.dist-info → uns_kit-0.0.7.dist-info}/METADATA +1 -1
- {uns_kit-0.0.6.dist-info → uns_kit-0.0.7.dist-info}/RECORD +9 -6
- {uns_kit-0.0.6.dist-info → uns_kit-0.0.7.dist-info}/WHEEL +0 -0
- {uns_kit-0.0.6.dist-info → uns_kit-0.0.7.dist-info}/entry_points.txt +0 -0
uns_kit/cli.py
CHANGED
|
@@ -131,6 +131,16 @@ def create(dest: str):
|
|
|
131
131
|
if os.path.exists(dest_path):
|
|
132
132
|
raise click.ClickException(f"Destination already exists: {dest_path}")
|
|
133
133
|
shutil.copytree(template_root, dest_path)
|
|
134
|
+
# personalize config with project name
|
|
135
|
+
config_path = Path(dest_path) / "config.json"
|
|
136
|
+
if config_path.exists():
|
|
137
|
+
try:
|
|
138
|
+
data = json.loads(config_path.read_text())
|
|
139
|
+
project_name = Path(dest_path).name
|
|
140
|
+
data.setdefault("uns", {})["packageName"] = project_name
|
|
141
|
+
config_path.write_text(json.dumps(data, indent=2))
|
|
142
|
+
except Exception:
|
|
143
|
+
pass
|
|
134
144
|
click.echo(f"Created UNS Python app at {dest_path}")
|
|
135
145
|
click.echo("Next steps:")
|
|
136
146
|
click.echo(f" 1) cd {dest_path}")
|
|
@@ -142,6 +152,7 @@ def create(dest: str):
|
|
|
142
152
|
@cli.command("write-config", help="Write a minimal config.json scaffold.")
|
|
143
153
|
@click.option("--path", default="config.json", show_default=True)
|
|
144
154
|
def write_config(path: str):
|
|
155
|
+
project_name = Path(path).resolve().parent.name
|
|
145
156
|
data = {
|
|
146
157
|
"infra": {
|
|
147
158
|
"host": "localhost",
|
|
@@ -155,7 +166,7 @@ def write_config(path: str):
|
|
|
155
166
|
"clean": True
|
|
156
167
|
},
|
|
157
168
|
"uns": {
|
|
158
|
-
"packageName":
|
|
169
|
+
"packageName": project_name,
|
|
159
170
|
"packageVersion": "0.0.1",
|
|
160
171
|
"processName": "uns-process"
|
|
161
172
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from uns_kit import UnsMqttClient, UnsPacket, TopicBuilder, UnsConfig
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def run():
|
|
9
|
+
# Load TS-style nested config
|
|
10
|
+
cfg = UnsConfig.load(Path("config.json"))
|
|
11
|
+
tb = cfg.topic_builder()
|
|
12
|
+
|
|
13
|
+
client = UnsMqttClient(
|
|
14
|
+
cfg.host,
|
|
15
|
+
port=cfg.port,
|
|
16
|
+
username=cfg.username,
|
|
17
|
+
password=cfg.password,
|
|
18
|
+
tls=cfg.tls,
|
|
19
|
+
client_id=cfg.client_id or f"{cfg.process_name}-py",
|
|
20
|
+
topic_builder=tb,
|
|
21
|
+
reconnect_interval=1,
|
|
22
|
+
)
|
|
23
|
+
await client.connect()
|
|
24
|
+
|
|
25
|
+
# Publish a startup heartbeat to raw/data/ (can be changed)
|
|
26
|
+
await client.publish_packet("raw/data/", UnsPacket.data(value="started", uom="state"))
|
|
27
|
+
|
|
28
|
+
# Idle loop; adjust to your workload
|
|
29
|
+
while True:
|
|
30
|
+
await asyncio.sleep(5)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if __name__ == "__main__":
|
|
34
|
+
asyncio.run(run())
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Placeholder package so Poetry can build a wheel.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
uns_kit/__init__.py,sha256=oLhYBOJkoYXBJGN7VDtJpMXAb1v5qFVphun5QgFwthw,564
|
|
2
|
-
uns_kit/cli.py,sha256=
|
|
2
|
+
uns_kit/cli.py,sha256=b0iKl978Wn39q2HA-y-sMPDHYzdEJQ9TX5yit_-RVqw,6202
|
|
3
3
|
uns_kit/client.py,sha256=GjlGOTPuaxeLlgkfcJWpxMId6nLeZNsZTNBfOYAe8YY,14892
|
|
4
4
|
uns_kit/config.py,sha256=K9FIvFB_zk59I_9XW5PA7sDRJOMl-5-3VCHbpyLgxyM,2899
|
|
5
5
|
uns_kit/packet.py,sha256=M-JJ0--FVe-iFPGnBUFynx_0iKB9F3NFwvETJ7yKibc,5874
|
|
@@ -7,13 +7,16 @@ uns_kit/proxy.py,sha256=H1Afs71rdb7DTHYp_8qeoM8uN5vOvAzYK50u9JszXQQ,2338
|
|
|
7
7
|
uns_kit/proxy_process.py,sha256=If8HXd_YAf1xYjzy8BA73Jo0DRh0-3WpHHIoVcIbS-Q,3906
|
|
8
8
|
uns_kit/status_monitor.py,sha256=8XXBaUHh8SW7gX4d3EtChnEkgQ7rnQ14tEHb0jDB25I,3022
|
|
9
9
|
uns_kit/templates/default/README.md,sha256=5_o_xowRuzHtn3NzibO-Ysq6iTTAuYbvtTFn27dH-yU,1251
|
|
10
|
-
uns_kit/templates/default/
|
|
10
|
+
uns_kit/templates/default/main.py,sha256=aD5o9FYl_5dBS-FQkB7kDXTMErmKQ360Qg9OdanJE0M,851
|
|
11
|
+
uns_kit/templates/default/pyproject.toml,sha256=KRPBGql4iVgBZIfdpOTNemPUdCBfvea3QHAb-tmh3jw,559
|
|
12
|
+
uns_kit/templates/default/runtime.json,sha256=TqLe6z6z3T4yCu0XfFcAl1B1KCheEcQPi3s1kM0e4CA,54
|
|
11
13
|
uns_kit/templates/default/src/data_example.py,sha256=8D1CyGVsbeKzZV79l8zaX-hqz_gxrA_ps2TA-GwzLQI,4381
|
|
12
14
|
uns_kit/templates/default/src/load_test.py,sha256=SjhycCOTz2Aw2si50iYGO8wHeQ9F_tFCMqLBALuEyJA,3290
|
|
15
|
+
uns_kit/templates/default/uns_py_app/__init__.py,sha256=3yOo4InP5WD5tN0Lu14mjd90_tmpcB0pGY0JG4wDMLc,51
|
|
13
16
|
uns_kit/topic_builder.py,sha256=UYC2SS9ptHopeyQ3ud1HEg1IHr5RJ7X2DEkfZC1CM5Y,1938
|
|
14
17
|
uns_kit/uns_mqtt_proxy.py,sha256=QzG0E42r7n33Z4Ri70-DxTlVoM-wj0_wAtnbMyaet08,9831
|
|
15
18
|
uns_kit/version.py,sha256=vmk-z_o25XOVgX5lSUrECllqau8NL7B_pkKsSmwhmX0,247
|
|
16
|
-
uns_kit-0.0.
|
|
17
|
-
uns_kit-0.0.
|
|
18
|
-
uns_kit-0.0.
|
|
19
|
-
uns_kit-0.0.
|
|
19
|
+
uns_kit-0.0.7.dist-info/METADATA,sha256=dYpmPtq3sb1jytz4j485mgtn6WHY_qrOaUduLcK4xrg,3306
|
|
20
|
+
uns_kit-0.0.7.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
|
|
21
|
+
uns_kit-0.0.7.dist-info/entry_points.txt,sha256=sLvTioiJQfGczUD-ODVx2xwwtHcGKjlIOn8t_Lt87Pg,47
|
|
22
|
+
uns_kit-0.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|