devicectl-core 0.1.0__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.
Files changed (66) hide show
  1. devicectl_core-0.1.0/.github/workflows/ci.yml +63 -0
  2. devicectl_core-0.1.0/.github/workflows/release.yml +69 -0
  3. devicectl_core-0.1.0/.gitignore +19 -0
  4. devicectl_core-0.1.0/CHANGELOG.md +35 -0
  5. devicectl_core-0.1.0/CONTRIBUTING.md +50 -0
  6. devicectl_core-0.1.0/LICENSE +287 -0
  7. devicectl_core-0.1.0/NOTICE +13 -0
  8. devicectl_core-0.1.0/PKG-INFO +131 -0
  9. devicectl_core-0.1.0/README.md +100 -0
  10. devicectl_core-0.1.0/biome.json +24 -0
  11. devicectl_core-0.1.0/pyproject.toml +135 -0
  12. devicectl_core-0.1.0/src/devicectl/__init__.py +18 -0
  13. devicectl_core-0.1.0/src/devicectl/cli/__init__.py +1 -0
  14. devicectl_core-0.1.0/src/devicectl/cli/command.py +95 -0
  15. devicectl_core-0.1.0/src/devicectl/cli/exits.py +32 -0
  16. devicectl_core-0.1.0/src/devicectl/cli/fanout.py +142 -0
  17. devicectl_core-0.1.0/src/devicectl/cli/main.py +69 -0
  18. devicectl_core-0.1.0/src/devicectl/cli/output.py +299 -0
  19. devicectl_core-0.1.0/src/devicectl/cli/parser.py +80 -0
  20. devicectl_core-0.1.0/src/devicectl/cli/report.py +86 -0
  21. devicectl_core-0.1.0/src/devicectl/cli/target.py +26 -0
  22. devicectl_core-0.1.0/src/devicectl/clock.py +57 -0
  23. devicectl_core-0.1.0/src/devicectl/devtools/__init__.py +6 -0
  24. devicectl_core-0.1.0/src/devicectl/devtools/frontlint.py +935 -0
  25. devicectl_core-0.1.0/src/devicectl/devtools/htmcheck.py +396 -0
  26. devicectl_core-0.1.0/src/devicectl/devtools/rendercheck.py +384 -0
  27. devicectl_core-0.1.0/src/devicectl/doctor.py +112 -0
  28. devicectl_core-0.1.0/src/devicectl/errors.py +68 -0
  29. devicectl_core-0.1.0/src/devicectl/fields.py +564 -0
  30. devicectl_core-0.1.0/src/devicectl/meta.py +64 -0
  31. devicectl_core-0.1.0/src/devicectl/paths.py +40 -0
  32. devicectl_core-0.1.0/src/devicectl/progress.py +77 -0
  33. devicectl_core-0.1.0/src/devicectl/report.py +67 -0
  34. devicectl_core-0.1.0/src/devicectl/testing.py +199 -0
  35. devicectl_core-0.1.0/src/devicectl/trace.py +333 -0
  36. devicectl_core-0.1.0/src/devicectl/web/__init__.py +1 -0
  37. devicectl_core-0.1.0/src/devicectl/web/agents.py +94 -0
  38. devicectl_core-0.1.0/src/devicectl/web/events.py +171 -0
  39. devicectl_core-0.1.0/src/devicectl/web/http.py +243 -0
  40. devicectl_core-0.1.0/src/devicectl/web/progress.py +101 -0
  41. devicectl_core-0.1.0/src/devicectl/web/server.py +1013 -0
  42. devicectl_core-0.1.0/src/devicectl/web/static/core.css +3034 -0
  43. devicectl_core-0.1.0/src/devicectl/web/static/js/api.js +198 -0
  44. devicectl_core-0.1.0/src/devicectl/web/static/js/band.js +640 -0
  45. devicectl_core-0.1.0/src/devicectl/web/static/js/chart.js +400 -0
  46. devicectl_core-0.1.0/src/devicectl/web/static/js/drafts.js +312 -0
  47. devicectl_core-0.1.0/src/devicectl/web/static/js/notify.js +272 -0
  48. devicectl_core-0.1.0/src/devicectl/web/static/js/panels.js +432 -0
  49. devicectl_core-0.1.0/src/devicectl/web/static/js/shell.js +672 -0
  50. devicectl_core-0.1.0/src/devicectl/web/static/js/trace.js +133 -0
  51. devicectl_core-0.1.0/src/devicectl/web/static/js/ui.js +1139 -0
  52. devicectl_core-0.1.0/src/devicectl/web/static/vendor/preact-htm.module.js +27 -0
  53. devicectl_core-0.1.0/src/devicectl/web/worker.py +697 -0
  54. devicectl_core-0.1.0/tests/test_cli.py +510 -0
  55. devicectl_core-0.1.0/tests/test_clock.py +31 -0
  56. devicectl_core-0.1.0/tests/test_core.py +255 -0
  57. devicectl_core-0.1.0/tests/test_events.py +110 -0
  58. devicectl_core-0.1.0/tests/test_fields.py +436 -0
  59. devicectl_core-0.1.0/tests/test_frontlint.py +671 -0
  60. devicectl_core-0.1.0/tests/test_htmcheck.py +238 -0
  61. devicectl_core-0.1.0/tests/test_http.py +194 -0
  62. devicectl_core-0.1.0/tests/test_meta.py +89 -0
  63. devicectl_core-0.1.0/tests/test_server.py +616 -0
  64. devicectl_core-0.1.0/tests/test_testing.py +268 -0
  65. devicectl_core-0.1.0/tests/test_trace.py +176 -0
  66. devicectl_core-0.1.0/uv.lock +352 -0
@@ -0,0 +1,63 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["**"]
6
+ # A pull request from a branch of this repository was already checked by
7
+ # the push above; listening to both would run every one of them twice.
8
+ # A fork's branch produces no push event here, so the `if` on each job
9
+ # below lets those -- and only those -- through.
10
+ pull_request:
11
+ # release.yml calls this workflow before it builds, so a tag cannot
12
+ # publish what the checks have not passed.
13
+ workflow_call:
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ # A newer commit on the same branch makes the older run's answer moot.
19
+ concurrency:
20
+ group: ci-${{ github.event.pull_request.number || github.ref }}
21
+ cancel-in-progress: true
22
+
23
+ jobs:
24
+ test:
25
+ if: >-
26
+ github.event_name != 'pull_request' ||
27
+ github.event.pull_request.head.repo.full_name != github.repository
28
+ runs-on: ubuntu-latest
29
+ strategy:
30
+ fail-fast: false
31
+ matrix:
32
+ python-version: ["3.10", "3.12", "3.14"]
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+ - uses: astral-sh/setup-uv@v5
36
+ with:
37
+ python-version: ${{ matrix.python-version }}
38
+ enable-cache: true
39
+ # --locked: a uv.lock that no longer matches pyproject.toml is a
40
+ # mistake to report, not one to paper over with a fresh resolution.
41
+ # The browser group brings the V8 the template check parses in;
42
+ # without it those tests skip themselves and check nothing.
43
+ - run: uv sync --locked --group browser
44
+ - run: uv run ruff format --check .
45
+ - run: uv run ruff check .
46
+ - run: uv run ty check
47
+ - run: uv run pytest
48
+
49
+ # Biome is one native binary and needs no Node; it lints the browser half
50
+ # once, not once per Python version. There is only the vendored bundle
51
+ # here today, which biome.json excludes -- this job is what keeps that
52
+ # true once core.css and the shared widgets arrive.
53
+ frontend:
54
+ if: >-
55
+ github.event_name != 'pull_request' ||
56
+ github.event.pull_request.head.repo.full_name != github.repository
57
+ runs-on: ubuntu-latest
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+ - uses: biomejs/setup-biome@v2
61
+ with:
62
+ version: 2.5.12
63
+ - run: biome ci
@@ -0,0 +1,69 @@
1
+ # Publishing, on a version tag. `git tag v0.1.0 && git push --tags` is the
2
+ # whole procedure; the tag has to match the version in
3
+ # src/devicectl/__init__.py, which is the one place it is written down.
4
+ name: Release
5
+
6
+ on:
7
+ push:
8
+ tags: ["v*"]
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ # The tag push does not itself trigger CI (its trigger is branches), so the
15
+ # checks run here. Nothing below starts until they are green.
16
+ ci:
17
+ uses: ./.github/workflows/ci.yml
18
+
19
+ build:
20
+ needs: ci
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: astral-sh/setup-uv@v5
25
+ - name: The tag and the package must agree
26
+ run: |
27
+ version=$(uv run --no-project python -c \
28
+ "import re,pathlib;print(re.search(r'\"(.+)\"',[l for l in pathlib.Path('src/devicectl/__init__.py').read_text().splitlines() if l.startswith('__version__')][0]).group(1))")
29
+ if [ "v$version" != "${GITHUB_REF_NAME}" ]; then
30
+ echo "tag ${GITHUB_REF_NAME} but __version__ is $version" >&2
31
+ exit 1
32
+ fi
33
+ - run: uv build
34
+ # A wheel that does not start is not worth publishing.
35
+ # A wheel that does not import is not worth publishing. There is no
36
+ # console script here: this is a library.
37
+ - run: uv run --no-project --with dist/*.whl python -c "import devicectl"
38
+ - uses: actions/upload-artifact@v4
39
+ with:
40
+ name: dist
41
+ path: dist/
42
+
43
+ publish:
44
+ needs: build
45
+ runs-on: ubuntu-latest
46
+ environment: pypi
47
+ permissions:
48
+ id-token: write # PyPI trusted publishing: no API token to keep anywhere
49
+ steps:
50
+ - uses: actions/download-artifact@v4
51
+ with:
52
+ name: dist
53
+ path: dist/
54
+ - uses: pypa/gh-action-pypi-publish@release/v1
55
+
56
+ github-release:
57
+ needs: publish
58
+ runs-on: ubuntu-latest
59
+ permissions:
60
+ contents: write
61
+ steps:
62
+ - uses: actions/checkout@v4
63
+ - uses: actions/download-artifact@v4
64
+ with:
65
+ name: dist
66
+ path: dist/
67
+ - run: gh release create "$GITHUB_REF_NAME" dist/* --generate-notes
68
+ env:
69
+ GH_TOKEN: ${{ github.token }}
@@ -0,0 +1,19 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+
5
+ # Virtual environments
6
+ .venv/
7
+
8
+ # Build artifacts
9
+ build/
10
+ dist/
11
+
12
+ # Tooling caches
13
+ .pytest_cache/
14
+ .ruff_cache/
15
+
16
+ # Editors
17
+ .idea/
18
+ .vscode/
19
+ *.swp
@@ -0,0 +1,35 @@
1
+ # Changelog
2
+
3
+ Notable changes, newest first. The version is set in
4
+ `src/devicectl/__init__.py`.
5
+
6
+ ## 0.1.0 — 2026-09-26
7
+
8
+ The first release. `alfenctl` and `jkctl` were one program written twice;
9
+ this is the half they share, extracted into one package with **no required
10
+ runtime dependencies** -- everything here is standard library.
11
+
12
+ What that half turned out to be:
13
+
14
+ - **Errors and reports.** `DeviceError`, the root of every expected failure;
15
+ `Reporter`, `Wait` and `SILENT`, the protocol that drives a terminal and a
16
+ browser from one long operation; and `Finding`, `Report` and `finding_json`,
17
+ the shape of a health check.
18
+ - **A CLI framework.** The command table (`Command`, `Need`, `Handler`), the
19
+ `argv` rewrites that fill in a default command or action, the fan-out that
20
+ runs one read across several devices, the shared exit codes, and the funnel
21
+ every expected failure lands in.
22
+ - **The web transport.** `serve()` and its four guards (Host, token, the UI
23
+ header, `--read-only`), the SSE event stream, the `Worker` that owns the one
24
+ connection a device allows, the upload spool, and `parse_listen`.
25
+ - **A build-free browser UI.** The design system (`core.css`) and the shared
26
+ widget library -- header, device tiles, tables, charts, draggable setpoint
27
+ bands, the health card and the page-wide draft store -- drawn over a vendored
28
+ Preact + htm, with no build step.
29
+ - **Dev-time checks.** `frontlint`, `htmcheck` and `rendercheck`, the
30
+ cross-file and in-browser checks that keep a build-free frontend honest.
31
+ - **Small shared helpers.** `FieldSpec`, one description of a setting for all
32
+ its audiences; `config_dir`, the per-user config directory by platform; the
33
+ duration and HTTP-status constants; and the clock-drift phrasing.
34
+
35
+ See [README.md](README.md) for the module-by-module map.
@@ -0,0 +1,50 @@
1
+ # Contributing
2
+
3
+ ## What belongs here
4
+
5
+ Something belongs in `devicectl-core` when **two** programs already need it
6
+ and neither's version is the right one to keep. One program's speculative
7
+ need is not enough: an abstraction with a single consumer is a guess, and
8
+ this package exists because a pair of guesses drifted apart in two repos
9
+ rather than being reconciled in one.
10
+
11
+ Three rules follow from that:
12
+
13
+ * **No runtime dependencies.** Everything here is standard library. A
14
+ transport belongs in the program that speaks the protocol.
15
+ * **Nothing here knows what a device is.** No retry policy, no register
16
+ catalog, no connection. The seam is always a callable or a dataclass the
17
+ program fills in.
18
+ * **Where the two programs disagree, reconcile before extracting.** Picking
19
+ one side and leaving the other to adapt is how the divergence started.
20
+
21
+ ## Conventions
22
+
23
+ Both consumer programs share these, and code moved from either keeps them.
24
+
25
+ * Docstrings on everything, enforced (`D`, pep257). They say *why*: what a
26
+ reader could work out from the code does not need repeating, and what
27
+ they could not -- a protocol quirk, a decision that looks arbitrary --
28
+ does.
29
+ * `PLR2004` is on, so a number with meaning gets a name.
30
+ * Line length 88, `E501` not enforced on prose. The formatter never breaks
31
+ a string, and some of them have to stay verbatim.
32
+ * Tests are named as sentences about behaviour, not after the function
33
+ under test.
34
+
35
+ ## Checks
36
+
37
+ ```bash
38
+ uv sync --group browser
39
+ uv run ruff check . && uv run ruff format --check . && uv run ty check && uv run pytest
40
+ ```
41
+
42
+ The `browser` group carries the V8 that `devtools/htmcheck.py` parses
43
+ templates in. Without it those tests skip themselves, saying so -- which
44
+ is fine locally and is why CI installs it.
45
+
46
+ ## Releasing
47
+
48
+ The version lives in `src/devicectl/__init__.py` and nowhere else.
49
+ `git tag v0.1.0 && git push --tags` runs the checks, builds, and publishes
50
+ to PyPI; the tag has to match.
@@ -0,0 +1,287 @@
1
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
2
+ EUPL © the European Union 2007, 2016
3
+
4
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined
5
+ below) which is provided under the terms of this Licence. Any use of the Work,
6
+ other than as authorised under this Licence is prohibited (to the extent such
7
+ use is covered by a right of the copyright holder of the Work).
8
+
9
+ The Work is provided under the terms of this Licence when the Licensor (as
10
+ defined below) has placed the following notice immediately following the
11
+ copyright notice for the Work:
12
+
13
+ Licensed under the EUPL
14
+
15
+ or has expressed by any other means his willingness to license under the EUPL.
16
+
17
+ 1. Definitions
18
+
19
+ In this Licence, the following terms have the following meaning:
20
+
21
+ - ‘The Licence’: this Licence.
22
+
23
+ - ‘The Original Work’: the work or software distributed or communicated by the
24
+ Licensor under this Licence, available as Source Code and also as Executable
25
+ Code as the case may be.
26
+
27
+ - ‘Derivative Works’: the works or software that could be created by the
28
+ Licensee, based upon the Original Work or modifications thereof. This Licence
29
+ does not define the extent of modification or dependence on the Original Work
30
+ required in order to classify a work as a Derivative Work; this extent is
31
+ determined by copyright law applicable in the country mentioned in Article 15.
32
+
33
+ - ‘The Work’: the Original Work or its Derivative Works.
34
+
35
+ - ‘The Source Code’: the human-readable form of the Work which is the most
36
+ convenient for people to study and modify.
37
+
38
+ - ‘The Executable Code’: any code which has generally been compiled and which is
39
+ meant to be interpreted by a computer as a program.
40
+
41
+ - ‘The Licensor’: the natural or legal person that distributes or communicates
42
+ the Work under the Licence.
43
+
44
+ - ‘Contributor(s)’: any natural or legal person who modifies the Work under the
45
+ Licence, or otherwise contributes to the creation of a Derivative Work.
46
+
47
+ - ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
48
+ the Work under the terms of the Licence.
49
+
50
+ - ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
51
+ renting, distributing, communicating, transmitting, or otherwise making
52
+ available, online or offline, copies of the Work or providing access to its
53
+ essential functionalities at the disposal of any other natural or legal
54
+ person.
55
+
56
+ 2. Scope of the rights granted by the Licence
57
+
58
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
59
+ sublicensable licence to do the following, for the duration of copyright vested
60
+ in the Original Work:
61
+
62
+ - use the Work in any circumstance and for all usage,
63
+ - reproduce the Work,
64
+ - modify the Work, and make Derivative Works based upon the Work,
65
+ - communicate to the public, including the right to make available or display
66
+ the Work or copies thereof to the public and perform publicly, as the case may
67
+ be, the Work,
68
+ - distribute the Work or copies thereof,
69
+ - lend and rent the Work or copies thereof,
70
+ - sublicense rights in the Work or copies thereof.
71
+
72
+ Those rights can be exercised on any media, supports and formats, whether now
73
+ known or later invented, as far as the applicable law permits so.
74
+
75
+ In the countries where moral rights apply, the Licensor waives his right to
76
+ exercise his moral right to the extent allowed by law in order to make effective
77
+ the licence of the economic rights here above listed.
78
+
79
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
80
+ any patents held by the Licensor, to the extent necessary to make use of the
81
+ rights granted on the Work under this Licence.
82
+
83
+ 3. Communication of the Source Code
84
+
85
+ The Licensor may provide the Work either in its Source Code form, or as
86
+ Executable Code. If the Work is provided as Executable Code, the Licensor
87
+ provides in addition a machine-readable copy of the Source Code of the Work
88
+ along with each copy of the Work that the Licensor distributes or indicates, in
89
+ a notice following the copyright notice attached to the Work, a repository where
90
+ the Source Code is easily and freely accessible for as long as the Licensor
91
+ continues to distribute or communicate the Work.
92
+
93
+ 4. Limitations on copyright
94
+
95
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from
96
+ any exception or limitation to the exclusive rights of the rights owners in the
97
+ Work, of the exhaustion of those rights or of other applicable limitations
98
+ thereto.
99
+
100
+ 5. Obligations of the Licensee
101
+
102
+ The grant of the rights mentioned above is subject to some restrictions and
103
+ obligations imposed on the Licensee. Those obligations are the following:
104
+
105
+ Attribution right: The Licensee shall keep intact all copyright, patent or
106
+ trademarks notices and all notices that refer to the Licence and to the
107
+ disclaimer of warranties. The Licensee must include a copy of such notices and a
108
+ copy of the Licence with every copy of the Work he/she distributes or
109
+ communicates. The Licensee must cause any Derivative Work to carry prominent
110
+ notices stating that the Work has been modified and the date of modification.
111
+
112
+ Copyleft clause: If the Licensee distributes or communicates copies of the
113
+ Original Works or Derivative Works, this Distribution or Communication will be
114
+ done under the terms of this Licence or of a later version of this Licence
115
+ unless the Original Work is expressly distributed only under this version of the
116
+ Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
117
+ (becoming Licensor) cannot offer or impose any additional terms or conditions on
118
+ the Work or Derivative Work that alter or restrict the terms of the Licence.
119
+
120
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative
121
+ Works or copies thereof based upon both the Work and another work licensed under
122
+ a Compatible Licence, this Distribution or Communication can be done under the
123
+ terms of this Compatible Licence. For the sake of this clause, ‘Compatible
124
+ Licence’ refers to the licences listed in the appendix attached to this Licence.
125
+ Should the Licensee's obligations under the Compatible Licence conflict with
126
+ his/her obligations under this Licence, the obligations of the Compatible
127
+ Licence shall prevail.
128
+
129
+ Provision of Source Code: When distributing or communicating copies of the Work,
130
+ the Licensee will provide a machine-readable copy of the Source Code or indicate
131
+ a repository where this Source will be easily and freely available for as long
132
+ as the Licensee continues to distribute or communicate the Work.
133
+
134
+ Legal Protection: This Licence does not grant permission to use the trade names,
135
+ trademarks, service marks, or names of the Licensor, except as required for
136
+ reasonable and customary use in describing the origin of the Work and
137
+ reproducing the content of the copyright notice.
138
+
139
+ 6. Chain of Authorship
140
+
141
+ The original Licensor warrants that the copyright in the Original Work granted
142
+ hereunder is owned by him/her or licensed to him/her and that he/she has the
143
+ power and authority to grant the Licence.
144
+
145
+ Each Contributor warrants that the copyright in the modifications he/she brings
146
+ to the Work are owned by him/her or licensed to him/her and that he/she has the
147
+ power and authority to grant the Licence.
148
+
149
+ Each time You accept the Licence, the original Licensor and subsequent
150
+ Contributors grant You a licence to their contributions to the Work, under the
151
+ terms of this Licence.
152
+
153
+ 7. Disclaimer of Warranty
154
+
155
+ The Work is a work in progress, which is continuously improved by numerous
156
+ Contributors. It is not a finished work and may therefore contain defects or
157
+ ‘bugs’ inherent to this type of development.
158
+
159
+ For the above reason, the Work is provided under the Licence on an ‘as is’ basis
160
+ and without warranties of any kind concerning the Work, including without
161
+ limitation merchantability, fitness for a particular purpose, absence of defects
162
+ or errors, accuracy, non-infringement of intellectual property rights other than
163
+ copyright as stated in Article 6 of this Licence.
164
+
165
+ This disclaimer of warranty is an essential part of the Licence and a condition
166
+ for the grant of any rights to the Work.
167
+
168
+ 8. Disclaimer of Liability
169
+
170
+ Except in the cases of wilful misconduct or damages directly caused to natural
171
+ persons, the Licensor will in no event be liable for any direct or indirect,
172
+ material or moral, damages of any kind, arising out of the Licence or of the use
173
+ of the Work, including without limitation, damages for loss of goodwill, work
174
+ stoppage, computer failure or malfunction, loss of data or any commercial
175
+ damage, even if the Licensor has been advised of the possibility of such damage.
176
+ However, the Licensor will be liable under statutory product liability laws as
177
+ far such laws apply to the Work.
178
+
179
+ 9. Additional agreements
180
+
181
+ While distributing the Work, You may choose to conclude an additional agreement,
182
+ defining obligations or services consistent with this Licence. However, if
183
+ accepting obligations, You may act only on your own behalf and on your sole
184
+ responsibility, not on behalf of the original Licensor or any other Contributor,
185
+ and only if You agree to indemnify, defend, and hold each Contributor harmless
186
+ for any liability incurred by, or claims asserted against such Contributor by
187
+ the fact You have accepted any warranty or additional liability.
188
+
189
+ 10. Acceptance of the Licence
190
+
191
+ The provisions of this Licence can be accepted by clicking on an icon ‘I agree’
192
+ placed under the bottom of a window displaying the text of this Licence or by
193
+ affirming consent in any other similar way, in accordance with the rules of
194
+ applicable law. Clicking on that icon indicates your clear and irrevocable
195
+ acceptance of this Licence and all of its terms and conditions.
196
+
197
+ Similarly, you irrevocably accept this Licence and all of its terms and
198
+ conditions by exercising any rights granted to You by Article 2 of this Licence,
199
+ such as the use of the Work, the creation by You of a Derivative Work or the
200
+ Distribution or Communication by You of the Work or copies thereof.
201
+
202
+ 11. Information to the public
203
+
204
+ In case of any Distribution or Communication of the Work by means of electronic
205
+ communication by You (for example, by offering to download the Work from a
206
+ remote location) the distribution channel or media (for example, a website) must
207
+ at least provide to the public the information requested by the applicable law
208
+ regarding the Licensor, the Licence and the way it may be accessible, concluded,
209
+ stored and reproduced by the Licensee.
210
+
211
+ 12. Termination of the Licence
212
+
213
+ The Licence and the rights granted hereunder will terminate automatically upon
214
+ any breach by the Licensee of the terms of the Licence.
215
+
216
+ Such a termination will not terminate the licences of any person who has
217
+ received the Work from the Licensee under the Licence, provided such persons
218
+ remain in full compliance with the Licence.
219
+
220
+ 13. Miscellaneous
221
+
222
+ Without prejudice of Article 9 above, the Licence represents the complete
223
+ agreement between the Parties as to the Work.
224
+
225
+ If any provision of the Licence is invalid or unenforceable under applicable
226
+ law, this will not affect the validity or enforceability of the Licence as a
227
+ whole. Such provision will be construed or reformed so as necessary to make it
228
+ valid and enforceable.
229
+
230
+ The European Commission may publish other linguistic versions or new versions of
231
+ this Licence or updated versions of the Appendix, so far this is required and
232
+ reasonable, without reducing the scope of the rights granted by the Licence. New
233
+ versions of the Licence will be published with a unique version number.
234
+
235
+ All linguistic versions of this Licence, approved by the European Commission,
236
+ have identical value. Parties can take advantage of the linguistic version of
237
+ their choice.
238
+
239
+ 14. Jurisdiction
240
+
241
+ Without prejudice to specific agreement between parties,
242
+
243
+ - any litigation resulting from the interpretation of this License, arising
244
+ between the European Union institutions, bodies, offices or agencies, as a
245
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
246
+ of Justice of the European Union, as laid down in article 272 of the Treaty on
247
+ the Functioning of the European Union,
248
+
249
+ - any litigation arising between other parties and resulting from the
250
+ interpretation of this License, will be subject to the exclusive jurisdiction
251
+ of the competent court where the Licensor resides or conducts its primary
252
+ business.
253
+
254
+ 15. Applicable Law
255
+
256
+ Without prejudice to specific agreement between parties,
257
+
258
+ - this Licence shall be governed by the law of the European Union Member State
259
+ where the Licensor has his seat, resides or has his registered office,
260
+
261
+ - this licence shall be governed by Belgian law if the Licensor has no seat,
262
+ residence or registered office inside a European Union Member State.
263
+
264
+ Appendix
265
+
266
+ ‘Compatible Licences’ according to Article 5 EUPL are:
267
+
268
+ - GNU General Public License (GPL) v. 2, v. 3
269
+ - GNU Affero General Public License (AGPL) v. 3
270
+ - Open Software License (OSL) v. 2.1, v. 3.0
271
+ - Eclipse Public License (EPL) v. 1.0
272
+ - CeCILL v. 2.0, v. 2.1
273
+ - Mozilla Public Licence (MPL) v. 2
274
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
275
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
276
+ works other than software
277
+ - European Union Public Licence (EUPL) v. 1.1, v. 1.2
278
+ - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
279
+ Reciprocity (LiLiQ-R+).
280
+
281
+ The European Commission may update this Appendix to later versions of the above
282
+ licences without producing a new version of the EUPL, as long as they provide
283
+ the rights granted in Article 2 of this Licence and protect the covered Source
284
+ Code from exclusive appropriation.
285
+
286
+ All other changes or additions to this Appendix require the production of a new
287
+ EUPL version.
@@ -0,0 +1,13 @@
1
+ NOTICE
2
+ ======
3
+
4
+ This project is licensed under the European Union Public Licence v1.2
5
+ (EUPL-1.2) -- see LICENSE. One file shipped in this distribution is not
6
+ covered by that license and remains under its own terms:
7
+
8
+ * ``src/devicectl/web/static/vendor/preact-htm.module.js`` -- Preact and
9
+ htm, bundled as one ES module. Copyright Jason Miller and contributors,
10
+ MIT License; the full notice is embedded as a comment at the top of the
11
+ file. Upstream: https://preactjs.com/ and https://github.com/developit/htm
12
+
13
+ Everything else in this distribution is licensed under the EUPL-1.2.
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.5
2
+ Name: devicectl-core
3
+ Version: 0.1.0
4
+ Summary: Shared building blocks for single-device control programs: a subcommand table, a serialising worker, an SSE broadcaster, and a build-free browser UI.
5
+ Project-URL: Homepage, https://github.com/pbasista/devicectl-core
6
+ Project-URL: Repository, https://github.com/pbasista/devicectl-core
7
+ Project-URL: Issues, https://github.com/pbasista/devicectl-core/issues
8
+ Project-URL: Releases, https://github.com/pbasista/devicectl-core/releases
9
+ Project-URL: License, https://github.com/pbasista/devicectl-core/blob/main/LICENSE
10
+ Author-email: Peter Bašista <pbasista@gmail.com>
11
+ License-Expression: EUPL-1.2
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Keywords: cli,device,embedded,framework,preact,server-sent-events,web-ui
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Environment :: Console
17
+ Classifier: Environment :: Web Environment
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
27
+ Classifier: Topic :: System :: Hardware
28
+ Classifier: Topic :: Utilities
29
+ Requires-Python: >=3.10
30
+ Description-Content-Type: text/markdown
31
+
32
+ # devicectl-core
33
+
34
+ Shared building blocks for programs that drive one device at a time: a
35
+ subcommand table, a progress protocol, a serialising worker that owns the
36
+ one connection a device allows, and a build-free browser UI -- its HTTP
37
+ server, its event stream and the design system it is drawn with.
38
+
39
+ It exists because two such programs -- [`alfenctl`][alfenctl] for an Alfen
40
+ wallbox on the network and [`jkctl`][jkctl] for a JK BMS on an RS485 bus --
41
+ turned out to be the same program with different protocols underneath, and
42
+ the second one was produced by copying the first. Line for line, after
43
+ normalising the two names, their frontend linters agreed on 528 lines out
44
+ of 529 and their event broadcasters on 161 out of 167. The drift had begun
45
+ anyway: fixes were being made on one side only. This package is the part
46
+ that was the same, with one name each.
47
+
48
+ ## What is here
49
+
50
+ | Module | What it holds |
51
+ |---|---|
52
+ | `devicectl.errors` | `DeviceError`, the root of every expected failure |
53
+ | `devicectl.report` | `Reporter`, `Wait`, `SILENT` |
54
+ | `devicectl.progress` | the stderr progress bar and the live line |
55
+ | `devicectl.doctor` | `Finding`, `Report`, `finding_json`, and the three weights |
56
+ | `devicectl.fields` | `FieldSpec`, one description of a setting for all its audiences |
57
+ | `devicectl.paths` | `config_dir`, the per-user config directory by platform |
58
+ | `devicectl.cli.command` | `Command`, `Need`, `Handler` |
59
+ | `devicectl.cli.exits` | the exit codes that mean the same thing everywhere |
60
+ | `devicectl.cli.target` | `first_set`, the one-line precedence rule |
61
+ | `devicectl.web.worker` | `Worker`, the one thread that owns the one connection |
62
+ | `devicectl.web.events` | `Broadcaster`, `Subscription`, `Event` |
63
+ | `devicectl.web.http` | `Request`, `Response`, `ApiError`, `Route`, the upload spool |
64
+ | `devicectl.web.server` | `serve`, `Branding`, `parse_listen`, and the four guards |
65
+ | `devicectl.devtools` | `frontlint`, `htmcheck` and `rendercheck`, run as `python -m` |
66
+ | `web/static/` | the design system (`core.css`) and the shared widget library, over the vendored Preact + htm |
67
+
68
+ ## What is deliberately not here
69
+
70
+ **Any runtime dependency.** Everything is standard library, so a program
71
+ that depends on this pays for its own protocol layer and nothing else --
72
+ and the package stays installable on a Raspberry Pi, where a dependency
73
+ with no armv7 wheel is a compiler run rather than a download.
74
+
75
+ **Anything that knows what a device is.** No transport, no retry policy, no
76
+ register catalog. Retry in particular does not generalise: one program
77
+ retries at the authentication layer (a 401 means log in again), the other
78
+ at the protocol layer (a framing fault is not a Modbus exception), and a
79
+ shared abstraction over the two would describe neither.
80
+
81
+ ## Using it
82
+
83
+ ```python
84
+ from devicectl.cli.command import Command, Need
85
+ from devicectl.errors import DeviceError
86
+ from devicectl.web import http
87
+
88
+
89
+ class WidgetError(DeviceError):
90
+ """Anything this program refuses to do, in one line."""
91
+
92
+
93
+ def get_state(ctx: "Context", req: http.Request) -> http.Response:
94
+ return http.ok({"ready": ctx.worker.ready})
95
+
96
+
97
+ ROUTES: dict[tuple[str, str], http.Route["Context"]] = {
98
+ ("GET", "/api/state"): http.Route(get_state),
99
+ }
100
+ ```
101
+
102
+ The frontend checks take the static root to check:
103
+
104
+ ```bash
105
+ python -m devicectl.devtools.frontlint src/widgetctl/web/static
106
+ python -m devicectl.devtools.htmcheck src/widgetctl/web/static
107
+ ```
108
+
109
+ `htmcheck` runs each `html` template through the real vendored parser
110
+ inside V8, so it needs an engine. That engine is ~80 MB and publishes no
111
+ armv7 wheel, so it lives in a dependency group of its own and the check
112
+ skips itself, saying so, without it:
113
+
114
+ ```bash
115
+ uv sync --group browser
116
+ ```
117
+
118
+ ## Development
119
+
120
+ ```bash
121
+ uv sync
122
+ uv run ruff check . && uv run ruff format --check . && uv run ty check && uv run pytest
123
+ ```
124
+
125
+ ## Licence
126
+
127
+ EUPL-1.2, except the vendored Preact + htm bundle, which is MIT -- see
128
+ `NOTICE`.
129
+
130
+ [alfenctl]: https://github.com/pbasista/alfenctl
131
+ [jkctl]: https://github.com/pbasista/jkctl