holocubic-cli-python 0.1.0a1__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 (26) hide show
  1. holocubic_cli_python-0.1.0a1/.gitignore +11 -0
  2. holocubic_cli_python-0.1.0a1/LICENSE +21 -0
  3. holocubic_cli_python-0.1.0a1/PKG-INFO +67 -0
  4. holocubic_cli_python-0.1.0a1/README.md +54 -0
  5. holocubic_cli_python-0.1.0a1/pyproject.toml +25 -0
  6. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/__init__.py +3 -0
  7. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/__main__.py +3 -0
  8. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/app.py +85 -0
  9. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/cli.py +543 -0
  10. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/client.py +375 -0
  11. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/config.py +133 -0
  12. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/errors.py +27 -0
  13. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/models.py +179 -0
  14. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/remote_path.py +62 -0
  15. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/transfer.py +661 -0
  16. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/transport.py +99 -0
  17. holocubic_cli_python-0.1.0a1/src/holocubic_cli_python/url.py +52 -0
  18. holocubic_cli_python-0.1.0a1/tests/mock_devtools.py +328 -0
  19. holocubic_cli_python-0.1.0a1/tests/test_app.py +49 -0
  20. holocubic_cli_python-0.1.0a1/tests/test_cli.py +116 -0
  21. holocubic_cli_python-0.1.0a1/tests/test_client.py +62 -0
  22. holocubic_cli_python-0.1.0a1/tests/test_config.py +55 -0
  23. holocubic_cli_python-0.1.0a1/tests/test_remote_path.py +40 -0
  24. holocubic_cli_python-0.1.0a1/tests/test_transfer.py +91 -0
  25. holocubic_cli_python-0.1.0a1/tests/test_url.py +36 -0
  26. holocubic_cli_python-0.1.0a1/uv.lock +8 -0
@@ -0,0 +1,11 @@
1
+ node_modules/
2
+ dist/
3
+ coverage/
4
+ *.tgz
5
+ .DS_Store
6
+ Thumbs.db
7
+ .cubic-test/
8
+ .venv/
9
+ __pycache__/
10
+ .pytest_cache/
11
+ target/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tim-1e
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.
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: holocubic-cli-python
3
+ Version: 0.1.0a1
4
+ Summary: Python CLI for HoloCubic DevTools file and app workflows
5
+ Project-URL: Repository, https://github.com/Tim-1e/holocubic-cli
6
+ Project-URL: Issues, https://github.com/Tim-1e/holocubic-cli/issues
7
+ Author: Tim-1e
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: cli,devtools,esp32,holocubic
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+
14
+ # HoloCubic CLI — Python
15
+
16
+ `cubic-py` is the Python implementation of the shared HoloCubic CLI v1
17
+ contract. It supports the same device configuration, SD-card filesystem,
18
+ recursive transfer, DevRun, and app workflows as the Node.js reference.
19
+
20
+ The package requires Python 3.10 or newer. It is source-ready but has not been
21
+ published to PyPI yet.
22
+
23
+ ## Installation from source
24
+
25
+ ```sh
26
+ python -m venv .venv
27
+ python -m pip install --editable .
28
+ cubic-py --version
29
+ ```
30
+
31
+ Activate `.venv` first if you want `cubic-py` available only inside the virtual
32
+ environment. Connect and inspect a device with:
33
+
34
+ ```sh
35
+ cubic-py device add desk 192.168.3.26
36
+ cubic-py info
37
+ cubic-py ls /sd/apps
38
+ cubic-py push ./my-app /sd/apps/my-app
39
+ ```
40
+
41
+ ## Command overview
42
+
43
+ ```text
44
+ cubic-py device add|list|use|remove
45
+ cubic-py ping|info
46
+ cubic-py ls|stat|cat|mkdir|mv|rm
47
+ cubic-py push|upload
48
+ cubic-py pull|download
49
+ cubic-py devrun read|save|run
50
+ cubic-py app list|install|remove
51
+ ```
52
+
53
+ Use `--host` for one-off access, `--json` for scripts, and `--help` on a command
54
+ for its transfer limits and safety options.
55
+
56
+ ## Development checks
57
+
58
+ ```sh
59
+ python -m ruff check src tests
60
+ python -m ruff format --check src tests
61
+ python -m unittest discover -s tests -v
62
+ python -m build
63
+ python -m pip install .
64
+ cubic-py --version
65
+ ```
66
+
67
+ The API and CLI contracts live in [`../../spec`](../../spec).
@@ -0,0 +1,54 @@
1
+ # HoloCubic CLI — Python
2
+
3
+ `cubic-py` is the Python implementation of the shared HoloCubic CLI v1
4
+ contract. It supports the same device configuration, SD-card filesystem,
5
+ recursive transfer, DevRun, and app workflows as the Node.js reference.
6
+
7
+ The package requires Python 3.10 or newer. It is source-ready but has not been
8
+ published to PyPI yet.
9
+
10
+ ## Installation from source
11
+
12
+ ```sh
13
+ python -m venv .venv
14
+ python -m pip install --editable .
15
+ cubic-py --version
16
+ ```
17
+
18
+ Activate `.venv` first if you want `cubic-py` available only inside the virtual
19
+ environment. Connect and inspect a device with:
20
+
21
+ ```sh
22
+ cubic-py device add desk 192.168.3.26
23
+ cubic-py info
24
+ cubic-py ls /sd/apps
25
+ cubic-py push ./my-app /sd/apps/my-app
26
+ ```
27
+
28
+ ## Command overview
29
+
30
+ ```text
31
+ cubic-py device add|list|use|remove
32
+ cubic-py ping|info
33
+ cubic-py ls|stat|cat|mkdir|mv|rm
34
+ cubic-py push|upload
35
+ cubic-py pull|download
36
+ cubic-py devrun read|save|run
37
+ cubic-py app list|install|remove
38
+ ```
39
+
40
+ Use `--host` for one-off access, `--json` for scripts, and `--help` on a command
41
+ for its transfer limits and safety options.
42
+
43
+ ## Development checks
44
+
45
+ ```sh
46
+ python -m ruff check src tests
47
+ python -m ruff format --check src tests
48
+ python -m unittest discover -s tests -v
49
+ python -m build
50
+ python -m pip install .
51
+ cubic-py --version
52
+ ```
53
+
54
+ The API and CLI contracts live in [`../../spec`](../../spec).
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.26,<2"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "holocubic-cli-python"
7
+ version = "0.1.0a1"
8
+ description = "Python CLI for HoloCubic DevTools file and app workflows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Tim-1e" }]
14
+ keywords = ["holocubic", "esp32", "cli", "devtools"]
15
+ dependencies = []
16
+
17
+ [project.scripts]
18
+ cubic-py = "holocubic_cli_python.cli:main"
19
+
20
+ [project.urls]
21
+ Repository = "https://github.com/Tim-1e/holocubic-cli"
22
+ Issues = "https://github.com/Tim-1e/holocubic-cli/issues"
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/holocubic_cli_python"]
@@ -0,0 +1,3 @@
1
+ """Python implementation of the HoloCubic CLI."""
2
+
3
+ __version__ = "0.1.0a1"
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,85 @@
1
+ """Local HoloCubic app validation."""
2
+
3
+ import os
4
+ import re
5
+ from dataclasses import dataclass
6
+ from pathlib import Path, PurePosixPath
7
+
8
+ from .errors import CubicError, UsageError
9
+ from .remote_path import remote_join
10
+
11
+
12
+ @dataclass(frozen=True)
13
+ class ValidatedApp:
14
+ source: Path
15
+ id: str
16
+ destination: str
17
+ entry: str
18
+
19
+ def public(self) -> dict[str, str]:
20
+ return {
21
+ "source": str(self.source),
22
+ "id": self.id,
23
+ "destination": self.destination,
24
+ "entry": self.entry,
25
+ }
26
+
27
+
28
+ def validate_app_id(value: str) -> str:
29
+ app_id = value.strip()
30
+ if (
31
+ not app_id
32
+ or app_id in {".", ".."}
33
+ or app_id.startswith(".cubic-")
34
+ or "/" in app_id
35
+ or "\\" in app_id
36
+ or any(ord(character) < 32 for character in app_id)
37
+ ):
38
+ raise UsageError(f"Invalid app id: {value}")
39
+ remote_join("/sd/apps", app_id)
40
+ return app_id
41
+
42
+
43
+ def _require_file(file_path: Path, label: str) -> None:
44
+ try:
45
+ if file_path.is_symlink() or not file_path.is_file():
46
+ raise OSError("not a regular file")
47
+ except OSError as error:
48
+ raise CubicError(
49
+ f"App {label} is missing or is not a regular file: {file_path}",
50
+ code="INVALID_APP",
51
+ ) from error
52
+
53
+
54
+ def validate_app_directory(
55
+ directory: str | Path, requested_id: str | None = None
56
+ ) -> ValidatedApp:
57
+ source = Path(os.path.abspath(os.fspath(directory)))
58
+ if source.is_symlink() or not source.is_dir():
59
+ raise CubicError(
60
+ f"App source is not a regular directory: {source}", code="INVALID_APP"
61
+ )
62
+ info_path = source / "app.info"
63
+ _require_file(info_path, "metadata")
64
+ try:
65
+ info = info_path.read_text(encoding="utf-8")
66
+ except (OSError, UnicodeDecodeError) as error:
67
+ raise CubicError(
68
+ f"Unable to read app metadata: {info_path}", code="INVALID_APP"
69
+ ) from error
70
+ match = re.search(r"^\s*entry\s*=\s*(.+?)\s*$", info, flags=re.MULTILINE)
71
+ entry = match.group(1).strip() if match else "main.lua"
72
+ pure_entry = PurePosixPath(entry)
73
+ if (
74
+ not entry
75
+ or pure_entry.is_absolute()
76
+ or ".." in pure_entry.parts
77
+ or "\\" in entry
78
+ ):
79
+ raise CubicError(
80
+ f"app.info declares an unsafe entry: {entry}", code="INVALID_APP"
81
+ )
82
+ _require_file(source.joinpath(*pure_entry.parts), "entry")
83
+ _require_file(source / "main.lua", "main.lua")
84
+ app_id = validate_app_id(requested_id if requested_id is not None else source.name)
85
+ return ValidatedApp(source, app_id, remote_join("/sd/apps", app_id), entry)