lotse-client 0.0.0.dev0__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.
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The lotse contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: lotse-client
3
+ Version: 0.0.0.dev0
4
+ Summary: Async client for the lotse media daemon's control API
5
+ Keywords: lotse,webrtc,rtsp,camera
6
+ License-Expression: MIT OR Apache-2.0
7
+ License-File: LICENSE-APACHE
8
+ License-File: LICENSE-MIT
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Framework :: AsyncIO
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: POSIX
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Home Automation
17
+ Classifier: Topic :: Multimedia :: Video
18
+ Classifier: Typing :: Typed
19
+ Requires-Dist: aiohttp>=3.12
20
+ Requires-Dist: mashumaro>=3.15
21
+ Requires-Dist: orjson>=3.10
22
+ Requires-Python: >=3.14
23
+ Project-URL: Repository, https://github.com/edenhaus/lotse-clients
24
+ Project-URL: Issues, https://github.com/edenhaus/lotse-clients/issues
25
+ Project-URL: Daemon, https://github.com/edenhaus/lotse
26
+ Description-Content-Type: text/markdown
27
+
28
+ # lotse-client
29
+
30
+ Async Python client for the control API of
31
+ [lotse](https://github.com/edenhaus/lotse), the media daemon for RTSP
32
+ cameras and WebRTC viewers. It speaks the API over the daemon's Unix socket with `aiohttp`;
33
+ the payload types are frozen dataclasses decoded with `mashumaro`.
34
+
35
+ ```python
36
+ from lotse_client import LotseClient
37
+ from lotse_client.models import SourceSpec
38
+
39
+ async with LotseClient("/run/lotse/lotse.sock") as client:
40
+ await client.stream.put(stream_id="front", sources=[SourceSpec(url="rtsp://cam/h264")])
41
+ async with await client.stream.subscribe(stream_id="front") as events:
42
+ async for event in events:
43
+ print(event)
44
+ ```
45
+
46
+ Every command is a keyword-only method named after it: `stream/put` is
47
+ `client.stream.put(...)`, `session/close` is `client.session.close(...)`,
48
+ and a command without a slash (`ping`, `info`, `schema`, `unsubscribe`) is a
49
+ method of the client. A command that subscribes (`stream.subscribe`,
50
+ `webrtc.offer`, `session.adopt`) returns a `Subscription`: an async iterator
51
+ of its events, which ends after a session's `closed` event or on
52
+ `unsubscribe`. A failed command raises `CommandError` with the stable error
53
+ `code`.
54
+
55
+ ## Generated code
56
+
57
+ `src/lotse_client/models.py` is generated by
58
+ [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator)
59
+ from the daemon's JSON Schema bundle (`../schema/api.json`, copied from
60
+ lotse's `crates/lotse-api-types/schema/api.json`, which is itself generated
61
+ from the Rust types); its options are in `pyproject.toml`.
62
+ `src/lotse_client/_commands.py` is then generated by
63
+ `scripts/generate_commands.py` from the bundle and those models: each
64
+ command's fields and their types come from its generated command class, its
65
+ result type and whether it subscribes from the bundle's `results` and
66
+ `events`. Do not edit either: change the Rust types in lotse, then copy the
67
+ bundle and regenerate with
68
+
69
+ ```sh
70
+ mise run schema # from the repository root; or, here,
71
+ uv run datamodel-codegen && uv run python scripts/generate_commands.py
72
+ ```
73
+
74
+ The `python-client` hook fails when either is stale, and
75
+ `tests/test_commands.py` checks the generator's output and what it refuses.
76
+
77
+ ## Development
78
+
79
+ ```sh
80
+ uv sync
81
+ uv run pytest # contract tests too when LOTSE_BIN names a lotse binary built with source-fake (`mise run contract`)
82
+ uv run ruff check && uv run ruff format --check && uv run mypy
83
+ ```
@@ -0,0 +1,56 @@
1
+ # lotse-client
2
+
3
+ Async Python client for the control API of
4
+ [lotse](https://github.com/edenhaus/lotse), the media daemon for RTSP
5
+ cameras and WebRTC viewers. It speaks the API over the daemon's Unix socket with `aiohttp`;
6
+ the payload types are frozen dataclasses decoded with `mashumaro`.
7
+
8
+ ```python
9
+ from lotse_client import LotseClient
10
+ from lotse_client.models import SourceSpec
11
+
12
+ async with LotseClient("/run/lotse/lotse.sock") as client:
13
+ await client.stream.put(stream_id="front", sources=[SourceSpec(url="rtsp://cam/h264")])
14
+ async with await client.stream.subscribe(stream_id="front") as events:
15
+ async for event in events:
16
+ print(event)
17
+ ```
18
+
19
+ Every command is a keyword-only method named after it: `stream/put` is
20
+ `client.stream.put(...)`, `session/close` is `client.session.close(...)`,
21
+ and a command without a slash (`ping`, `info`, `schema`, `unsubscribe`) is a
22
+ method of the client. A command that subscribes (`stream.subscribe`,
23
+ `webrtc.offer`, `session.adopt`) returns a `Subscription`: an async iterator
24
+ of its events, which ends after a session's `closed` event or on
25
+ `unsubscribe`. A failed command raises `CommandError` with the stable error
26
+ `code`.
27
+
28
+ ## Generated code
29
+
30
+ `src/lotse_client/models.py` is generated by
31
+ [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator)
32
+ from the daemon's JSON Schema bundle (`../schema/api.json`, copied from
33
+ lotse's `crates/lotse-api-types/schema/api.json`, which is itself generated
34
+ from the Rust types); its options are in `pyproject.toml`.
35
+ `src/lotse_client/_commands.py` is then generated by
36
+ `scripts/generate_commands.py` from the bundle and those models: each
37
+ command's fields and their types come from its generated command class, its
38
+ result type and whether it subscribes from the bundle's `results` and
39
+ `events`. Do not edit either: change the Rust types in lotse, then copy the
40
+ bundle and regenerate with
41
+
42
+ ```sh
43
+ mise run schema # from the repository root; or, here,
44
+ uv run datamodel-codegen && uv run python scripts/generate_commands.py
45
+ ```
46
+
47
+ The `python-client` hook fails when either is stale, and
48
+ `tests/test_commands.py` checks the generator's output and what it refuses.
49
+
50
+ ## Development
51
+
52
+ ```sh
53
+ uv sync
54
+ uv run pytest # contract tests too when LOTSE_BIN names a lotse binary built with source-fake (`mise run contract`)
55
+ uv run ruff check && uv run ruff format --check && uv run mypy
56
+ ```
@@ -0,0 +1,122 @@
1
+ [project]
2
+ name = "lotse-client"
3
+ version = "0.0.0-dev"
4
+ description = "Async client for the lotse media daemon's control API"
5
+ readme = "README.md"
6
+ license = "MIT OR Apache-2.0"
7
+ license-files = [
8
+ "LICENSE-MIT",
9
+ "LICENSE-APACHE",
10
+ ]
11
+ requires-python = ">=3.14"
12
+ keywords = [
13
+ "lotse",
14
+ "webrtc",
15
+ "rtsp",
16
+ "camera",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Framework :: AsyncIO",
21
+ "Intended Audience :: Developers",
22
+ "Operating System :: POSIX",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3 :: Only",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Topic :: Home Automation",
27
+ "Topic :: Multimedia :: Video",
28
+ "Typing :: Typed",
29
+ ]
30
+ dependencies = [
31
+ "aiohttp>=3.12",
32
+ "mashumaro>=3.15",
33
+ "orjson>=3.10",
34
+ ]
35
+
36
+ [project.urls]
37
+ Repository = "https://github.com/edenhaus/lotse-clients"
38
+ Issues = "https://github.com/edenhaus/lotse-clients/issues"
39
+ Daemon = "https://github.com/edenhaus/lotse"
40
+
41
+ [dependency-groups]
42
+ dev = [
43
+ "datamodel-code-generator==0.83.0",
44
+ "mypy==2.4.0",
45
+ "pytest==9.1.1",
46
+ "pytest-asyncio==1.4.0",
47
+ "pytest-cov==7.1.0",
48
+ "ruff==0.16.10",
49
+ ]
50
+ release = ["twine==7.0.0"]
51
+
52
+ [build-system]
53
+ requires = ["uv_build>=0.12,<0.13"]
54
+ build-backend = "uv_build"
55
+
56
+ [tool.ruff]
57
+ target-version = "py314"
58
+ line-length = 100
59
+ extend-exclude = ["src/lotse_client/models.py"]
60
+
61
+ [tool.ruff.lint]
62
+ select = ["ALL"]
63
+ ignore = [
64
+ "COM812",
65
+ "CPY001",
66
+ ]
67
+
68
+ [tool.ruff.lint.pydocstyle]
69
+ convention = "google"
70
+
71
+ [tool.ruff.lint.per-file-ignores]
72
+ "tests/*" = [
73
+ "D1",
74
+ "PLR2004",
75
+ "S101",
76
+ "SLF001",
77
+ ]
78
+ "scripts/*" = ["S603"]
79
+
80
+ [tool.mypy]
81
+ strict = true
82
+ python_version = "3.14"
83
+ files = [
84
+ "src",
85
+ "tests",
86
+ "scripts",
87
+ ]
88
+
89
+ [tool.pytest.ini_options]
90
+ pythonpath = ["."]
91
+ testpaths = ["tests"]
92
+ asyncio_mode = "auto"
93
+ asyncio_default_fixture_loop_scope = "function"
94
+ addopts = "--strict-markers --cov=lotse_client --cov=scripts --cov-branch --cov-report=term-missing --cov-fail-under=100"
95
+ filterwarnings = ["error"]
96
+
97
+ [tool.coverage.report]
98
+ exclude_also = ['if __name__ == "__main__":']
99
+
100
+ [tool.datamodel-codegen]
101
+ input = "../schema/api.json"
102
+ input-file-type = "jsonschema"
103
+ output = "src/lotse_client/models.py"
104
+ output-model-type = "dataclasses.dataclass"
105
+ target-python-version = "3.14"
106
+ base-class = "lotse_client._base.Model"
107
+ frozen-dataclasses = true
108
+ keyword-only = true
109
+ enum-field-as-literal = "all"
110
+ use-one-literal-as-default = true
111
+ use-schema-description = true
112
+ use-field-description = true
113
+ use-title-as-name = true
114
+ use-union-operator = true
115
+ strict-nullable = true
116
+ use-standard-collections = true
117
+ disable-timestamp = true
118
+ formatters = ["ruff-format"]
119
+ custom-file-header = """
120
+ # Generated by datamodel-code-generator from schema/api.json.
121
+ # Do not edit: change the Rust types in lotse, copy its bundle to schema/, then
122
+ # run `uv run datamodel-codegen` in python/."""
@@ -0,0 +1,127 @@
1
+ # The Python client of the lotse control API. The models are generated from the
2
+ # JSON Schema bundle in ../schema by datamodel-code-generator (`uv run
3
+ # datamodel-codegen`, configured below) and the command methods from the bundle and
4
+ # those models by scripts/generate_commands.py; the WebSocket transport is hand-written.
5
+
6
+ [project]
7
+ name = "lotse-client"
8
+ # The lotse release whose API bundle schema/api.json is; 0.0.0 until the first. Changing it on
9
+ # main releases it to PyPI (.github/workflows/release.yml, ../README.md#releasing).
10
+ version = "0.0.0-dev"
11
+ description = "Async client for the lotse media daemon's control API"
12
+ readme = "README.md"
13
+ license = "MIT OR Apache-2.0" # PEP 639: an SPDX expression, so no license classifier
14
+ license-files = ["LICENSE-MIT", "LICENSE-APACHE"] # symlinks to the repository's
15
+ requires-python = ">=3.14"
16
+ keywords = ["lotse", "webrtc", "rtsp", "camera"]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha", # lotse is pre-1.0, and so is its API
19
+ "Framework :: AsyncIO",
20
+ "Intended Audience :: Developers",
21
+ "Operating System :: POSIX", # the daemon is reached over a Unix socket
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3 :: Only",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Topic :: Home Automation",
26
+ "Topic :: Multimedia :: Video",
27
+ "Typing :: Typed",
28
+ ]
29
+ dependencies = [
30
+ "aiohttp>=3.12", # the WebSocket over the Unix socket
31
+ "mashumaro>=3.15", # decoding and encoding the generated dataclasses
32
+ "orjson>=3.10", # mashumaro's JSON mixin and the frames on the wire
33
+ ]
34
+
35
+ [project.urls]
36
+ Repository = "https://github.com/edenhaus/lotse-clients"
37
+ Issues = "https://github.com/edenhaus/lotse-clients/issues"
38
+ Daemon = "https://github.com/edenhaus/lotse"
39
+
40
+ [dependency-groups]
41
+ dev = [
42
+ "datamodel-code-generator==0.83.0",
43
+ "mypy==2.4.0",
44
+ "pytest==9.1.1",
45
+ "pytest-asyncio==1.4.0",
46
+ "pytest-cov==7.1.0",
47
+ "ruff==0.16.10",
48
+ ]
49
+ # `mise run dist`: the metadata PyPI renders, checked before the release uploads it.
50
+ release = ["twine==7.0.0"]
51
+
52
+ [build-system]
53
+ requires = ["uv_build>=0.12,<0.13"]
54
+ build-backend = "uv_build"
55
+
56
+ [tool.ruff]
57
+ target-version = "py314"
58
+ line-length = 100 # rustfmt's width, as in the Rust code
59
+ # Tool output, formatted by the generator itself and guarded by `datamodel-codegen --check`.
60
+ extend-exclude = ["src/lotse_client/models.py"]
61
+
62
+ [tool.ruff.lint]
63
+ select = ["ALL"]
64
+ ignore = [
65
+ "COM812", # conflicts with the formatter (ruff warns when both are on)
66
+ "CPY001", # no file in the repository carries a copyright header; the license is in LICENSE-*
67
+ ]
68
+
69
+
70
+ [tool.ruff.lint.pydocstyle]
71
+ convention = "google"
72
+
73
+ [tool.ruff.lint.per-file-ignores]
74
+ # What conflicts with pytest and with the tests' conventions, as the Rust tests relax
75
+ # the production-only lints (lotse's AGENTS.md).
76
+ "tests/*" = [
77
+ "D1", # test names are the docs
78
+ "PLR2004", # expected values are written inline
79
+ "S101", # pytest's assertions are plain `assert`
80
+ "SLF001", # tests drive the transport's internals (a cancelled wait, a failed send)
81
+ ]
82
+ # The command generator runs the environment's ruff on its output, with fixed arguments.
83
+ "scripts/*" = ["S603"]
84
+
85
+ [tool.mypy]
86
+ strict = true
87
+ python_version = "3.14"
88
+ files = ["src", "tests", "scripts"]
89
+
90
+ [tool.pytest.ini_options]
91
+ pythonpath = ["."]
92
+ testpaths = ["tests"]
93
+ asyncio_mode = "auto"
94
+ asyncio_default_fixture_loop_scope = "function"
95
+ addopts = "--strict-markers --cov=lotse_client --cov=scripts --cov-branch --cov-report=term-missing --cov-fail-under=100"
96
+ filterwarnings = ["error"]
97
+
98
+ [tool.coverage.report]
99
+ # A script's entry point runs only from the command line; the tests call `main`.
100
+ exclude_also = ['if __name__ == "__main__":']
101
+
102
+
103
+ # `uv run datamodel-codegen` writes src/lotse_client/models.py from the bundle, and
104
+ # `uv run python scripts/generate_commands.py` then writes _commands.py from both;
105
+ # `--check` on either fails when its output is stale (the python-client hook).
106
+ [tool.datamodel-codegen]
107
+ input = "../schema/api.json"
108
+ input-file-type = "jsonschema"
109
+ output = "src/lotse_client/models.py"
110
+ output-model-type = "dataclasses.dataclass"
111
+ target-python-version = "3.14"
112
+ base-class = "lotse_client._base.Model" # mashumaro, leaving out None when encoding
113
+ frozen-dataclasses = true
114
+ keyword-only = true
115
+ enum-field-as-literal = "all"
116
+ use-one-literal-as-default = true
117
+ use-schema-description = true
118
+ use-field-description = true
119
+ use-title-as-name = true
120
+ use-union-operator = true
121
+ strict-nullable = true # a defaulted field is not nullable unless the schema says so
122
+ use-standard-collections = true
123
+ disable-timestamp = true
124
+ formatters = ["ruff-format"]
125
+ custom-file-header = """# Generated by datamodel-code-generator from schema/api.json.
126
+ # Do not edit: change the Rust types in lotse, copy its bundle to schema/, then
127
+ # run `uv run datamodel-codegen` in python/."""
@@ -0,0 +1,30 @@
1
+ """Async client for the control API of lotse, the media daemon for RTSP cameras and WebRTC viewers.
2
+
3
+ `LotseClient` speaks the API over the daemon's Unix socket; the payload types
4
+ are in `lotse_client.models`, generated with the command methods from the
5
+ daemon's JSON Schema.
6
+ """
7
+
8
+ from lotse_client.client import LotseClient
9
+ from lotse_client.errors import (
10
+ ApiVersionError,
11
+ CannotConnectError,
12
+ CommandError,
13
+ ConnectionClosedError,
14
+ LotseError,
15
+ ProtocolError,
16
+ )
17
+ from lotse_client.subscription import Subscription
18
+ from lotse_client.version import API_VERSION
19
+
20
+ __all__ = [
21
+ "API_VERSION",
22
+ "ApiVersionError",
23
+ "CannotConnectError",
24
+ "CommandError",
25
+ "ConnectionClosedError",
26
+ "LotseClient",
27
+ "LotseError",
28
+ "ProtocolError",
29
+ "Subscription",
30
+ ]
@@ -0,0 +1,19 @@
1
+ """The base class of every generated model.
2
+
3
+ Encoding omits fields that are `None`: the daemon rejects a `null` where the
4
+ Rust type has a default but no `Option` (a source's `options`, for one), and
5
+ leaving a field out always means its default. Decoding ignores fields it does
6
+ not know, because a newer daemon may add them without an API version bump.
7
+ """
8
+
9
+ from mashumaro.config import BaseConfig
10
+ from mashumaro.mixins.orjson import DataClassORJSONMixin
11
+
12
+
13
+ class Model(DataClassORJSONMixin):
14
+ """A message type of the control API, encoded and decoded by mashumaro."""
15
+
16
+ class Config(BaseConfig):
17
+ """Leave out `None` when encoding."""
18
+
19
+ omit_none = True