Commit 7520fc9
Introduce flask-less CLI interface (e.g. for programmatic DB access) (#1909)
Resolves #1690.
(Successor of tiny-pilot/tinypilot-pro#1602.)
This PR introduces a new, internal Flask-less CLI entrypoint to our app,
for programmatic access of certain features (mainly DB-related).
As a first use-case, it migrates the `streaming-mode` CLI command,
mainly to demonstrate how this is intended to be used. We’ll soon [add
another command for retrieving the serial
settings](tiny-pilot/tinypilot-pro#1332 (comment)).
In a subsequent step, we can also migrate [the last remaining command
for activating a
license](https://github.com/tiny-pilot/tinypilot-pro/blob/b93dc93f4f2581118325ffe9eaa30d7f5fefae26/app/flask_cli.py#L13-L21)
and thereby sunset the Flask CLI entrypoint altogether. (I’d create a
separate ticket for that.)
## Notes
- Although the footprint of the CLI functionality is still quite small
(and is unlikely to grow substantially in the near-to-mid future), I
thought that a separate Python module (directory) was warranted
(`app/cli`). That way, we hopefully have a clearer separation from the
web app, and we are also a bit more flexible to structure the code
nicely.
- I introduced a `@command` annotation to make it convenient to register
commands. My thinking is not to go overboard with this, though – e.g.,
I’d not expand this mechanism to include arg-parsing etc., as it would
then probably make more sense to rather keep the Flask CLI or introduce
another framework. The main intention of `@command` is to have all
command-related code closely together, as opposed to having to define
the function in one place and then “register” it in a second. Since the
whole CLI is more of an internal helper utility, I think it’s fair to
keep the whole structure basic.
<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1909"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>
---------
Co-authored-by: Jan Heuermann <[email protected]>1 parent 8c2bbdd commit 7520fc9
File tree
9 files changed
+85
-35
lines changed- app
- cli
- debian-pkg/opt/tinypilot-privileged/scripts
- scripts
9 files changed
+85
-35
lines changedThis file was deleted.
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
14 | 23 | | |
15 | 24 | | |
16 | | - | |
| 25 | + | |
17 | 26 | | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
21 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
22 | 39 | | |
23 | 40 | | |
24 | 41 | | |
25 | 42 | | |
26 | | - | |
| 43 | + | |
27 | 44 | | |
28 | 45 | | |
29 | 46 | | |
30 | | - | |
| 47 | + | |
31 | 48 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
52 | | - | |
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| |||
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | | - | |
22 | 26 | | |
23 | | - | |
24 | | - | |
| 27 | + | |
| 28 | + | |
0 commit comments