shvcli-ell 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.
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: shvcli-ell
3
+ Version: 0.1.0
4
+ Summary: Silicon Heaven CLI Elektroline extension
5
+ Author: Elektroline a.s.
6
+ Project-URL: source, https://gitlab.com/elektroline-predator/shvcli-ell
7
+ Project-URL: changelog, https://gitlab.com/elektroline-predator/shvcli-ell/-/blob/master/CHANGELOG.md
8
+ Project-URL: issues, https://gitlab.com/elektroline-predator/shvcli-ell/-/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/x-rst
13
+ Requires-Dist: shvcli>=0.7.0
14
+
15
+ Silicon Heaven CLI Elektroline extension
16
+ ========================================
17
+
18
+ The extension for the Silicon Heaven CLI access application to provide utilities
19
+ to work with Elektroline developed SHV systems.
20
+
21
+ * `📃 Sources <https://gitlab.com/elektroline-predator/shvcli-ell>`__
22
+ * `⁉️ Issue tracker <https://gitlab.com/elektroline-predator/shvcli-ell/-/issues>`__
23
+ * `Silicon Heaven CLI <https://gitlab.com/silicon-heaven/shvcli>`__
@@ -0,0 +1,9 @@
1
+ Silicon Heaven CLI Elektroline extension
2
+ ========================================
3
+
4
+ The extension for the Silicon Heaven CLI access application to provide utilities
5
+ to work with Elektroline developed SHV systems.
6
+
7
+ * `📃 Sources <https://gitlab.com/elektroline-predator/shvcli-ell>`__
8
+ * `⁉️ Issue tracker <https://gitlab.com/elektroline-predator/shvcli-ell/-/issues>`__
9
+ * `Silicon Heaven CLI <https://gitlab.com/silicon-heaven/shvcli>`__
@@ -0,0 +1,78 @@
1
+ [project]
2
+ name = "shvcli-ell"
3
+ version = "0.1.0"
4
+ description = "Silicon Heaven CLI Elektroline extension"
5
+ readme = "README.rst"
6
+ authors = [
7
+ { name="Elektroline a.s." },
8
+ ]
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "Operating System :: OS Independent",
12
+ ]
13
+ requires-python = ">=3.11"
14
+ dependencies = [
15
+ "shvcli >= 0.7.0",
16
+ ]
17
+
18
+ [project.urls]
19
+ source = "https://gitlab.com/elektroline-predator/shvcli-ell"
20
+ changelog = "https://gitlab.com/elektroline-predator/shvcli-ell/-/blob/master/CHANGELOG.md"
21
+ issues = "https://gitlab.com/elektroline-predator/shvcli-ell/-/issues"
22
+
23
+ [project.entry-points."shvcli.plugins"]
24
+ ell = "shvcli_ell.plugin"
25
+
26
+ [build-system]
27
+ requires = ["setuptools"]
28
+ build-backend = "setuptools.build_meta"
29
+
30
+ [tool.setuptools.package-data]
31
+ "*" = ["py.typed"]
32
+ [tool.setuptools.cmdclass]
33
+ build_py = "shvcli_ell.__setuptools__.BuildPy"
34
+
35
+ [tool.ruff]
36
+ target-version = "py311"
37
+ [tool.ruff.lint]
38
+ select = [
39
+ "F", "E", "W", "I", "N", "D", "UP", "YTT", "ANN", "ASYNC", "ASYNC1", "S", "BLE",
40
+ "B", "A", "COM", "PL", "RUF"
41
+ ]
42
+ ignore = [
43
+ # Magic methods have defined behavior so what is there to document. __init__
44
+ # should be documented in class docstring.
45
+ "D105", "D107",
46
+ # These have conflicting rules.
47
+ "D203", "D213",
48
+ # Ignore too long lines (format tackles that)
49
+ "E501",
50
+ # It is nice that assert should not be used for input checking but it can be
51
+ # also used for internal consistency checking.
52
+ "S101", "B011",
53
+ # subprocess can be insecurely used but not is insecure by design
54
+ "S404", "S603", "S607",
55
+ # Catching Exception is valid and safe in some cases and thus should be allowed
56
+ "BLE001",
57
+ # Conflict with formatter
58
+ "COM812",
59
+ # Remove too-many limit for more complex code.
60
+ "PLR0904", "PLR0911", "PLR0912", "PLR0913", "PLR0917", "PLR2004", "PLR1702",
61
+ # This seems like a wrong rule
62
+ "PLW1641",
63
+ ]
64
+ preview = true
65
+ [tool.ruff.lint.per-file-ignores]
66
+ "docs/conf.py" = ["D100", "D103", "A001", "ANN201", "ANN001"]
67
+ [tool.ruff.format]
68
+ docstring-code-format = true
69
+ preview = true
70
+
71
+ [tool.mypy]
72
+ python_version = "3.11"
73
+ ignore_missing_imports = true
74
+ disallow_untyped_defs = true
75
+ warn_redundant_casts = true
76
+ warn_unused_ignores = true
77
+ warn_return_any = true
78
+ warn_unreachable = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """Simple counter of strings of this package name.
2
+
3
+ This package is base for the packages to be implemented.
4
+ """
5
+
6
+ from .__version__ import VERSION
7
+
8
+ __all__ = ["VERSION"]
@@ -0,0 +1,18 @@
1
+ """Setuptools hook used to replace __version__.py file."""
2
+
3
+ import pathlib
4
+
5
+ from setuptools.command.build_py import build_py as _build_py
6
+
7
+
8
+ class BuildPy(_build_py):
9
+ """Custom package build step."""
10
+
11
+ def run(self) -> None: # noqa: D102
12
+ package = pathlib.Path(__file__).parent.name
13
+ buildlib = pathlib.Path(self.build_lib) / package
14
+ buildlib.mkdir(parents=True, exist_ok=True)
15
+ version = self.distribution.metadata.version
16
+ (buildlib / "__version__.py").write_text(f'VERSION = "{version}"\n')
17
+ super().run()
18
+ (buildlib / "__setuptools__.py").unlink()
@@ -0,0 +1,24 @@
1
+ """The loader of the version for source file only installation.
2
+
3
+ It looks for pyproject.toml file in upper directory and loads version from
4
+ there.
5
+
6
+ This file is overwritten during distribution build to contain only constant
7
+ VERSION. Please see __setuptools__.py for details.
8
+ """
9
+
10
+ import pathlib
11
+ import tomllib
12
+
13
+
14
+ def _get_version() -> str:
15
+ pyproject = pathlib.Path(__file__).parent.parent / "pyproject.toml"
16
+ if pyproject.exists():
17
+ with pyproject.open("rb") as f:
18
+ res = tomllib.load(f)["project"]["version"]
19
+ if isinstance(res, str):
20
+ return res
21
+ return "unknown"
22
+
23
+
24
+ VERSION = _get_version()
@@ -0,0 +1,6 @@
1
+ """The top level loaded for the plugin."""
2
+
3
+ import importlib
4
+
5
+ importlib.import_module(".timesync", __package__)
6
+ importlib.import_module(".timezone", __package__)
File without changes
@@ -0,0 +1,56 @@
1
+ """The builtin to sync time of NuttX based devices."""
2
+
3
+ import collections.abc
4
+ import datetime
5
+
6
+ from prompt_toolkit.completion import Completion
7
+ from shvcli import Builtin, Builtins, Client, CliItems, State, Tree
8
+ from shvcli.tools.complet import comp_path
9
+
10
+
11
+ class BuiltinTimeSync(Builtin):
12
+ """The builtin for time synchronization of ``utcTime`` with local one."""
13
+
14
+ def __init__(self, builtins: Builtins, state: State) -> None:
15
+ super().__init__(builtins, state)
16
+ builtins["timesync"] = self
17
+
18
+ @property
19
+ def description(self) -> tuple[str, str]: # noqa: D102
20
+ return "[PATH]", "Synchronize the time of the board with the local time."
21
+
22
+ def completion( # noqa: D102
23
+ self, items: CliItems, client: Client
24
+ ) -> collections.abc.Iterable[Completion]:
25
+ yield from comp_path(items.param, self.state.path, Tree(self.state), "")
26
+
27
+ async def completion_async( # noqa: D102
28
+ self, items: CliItems, client: Client
29
+ ) -> collections.abc.AsyncGenerator[Completion, None]:
30
+ await client.probe(
31
+ items.path_param if items.param.endswith("/") else items.path_param.parent
32
+ )
33
+
34
+ async for res in super().completion_async(items, client):
35
+ yield res
36
+
37
+ async def run(self, items: CliItems, client: Client) -> None: # noqa: PLR6301, D102
38
+ path = items.path_param
39
+ if path.name != "utcTime":
40
+ path /= "utcTime"
41
+ got = await client.call(str(path), "get")
42
+ if not isinstance(got, datetime.datetime):
43
+ print(f"Unexpected result of {path}:get: {got}")
44
+ return
45
+
46
+ now = datetime.datetime.now(datetime.UTC)
47
+ diff = now - got
48
+ drift = datetime.timedelta(milliseconds=500)
49
+ if not (-drift <= diff <= drift):
50
+ await client.call(str(path), "set", now)
51
+ print(f"Time synchronized. The difference: {diff}")
52
+ else:
53
+ print(
54
+ "Time is syncrhonized withing half a second tolerance. "
55
+ f"The difference: {diff}"
56
+ )
@@ -0,0 +1,56 @@
1
+ """The builtin to set local time time of NuttX based devices."""
2
+
3
+ import collections.abc
4
+ import pathlib
5
+ import zoneinfo
6
+
7
+ from prompt_toolkit.completion import Completion
8
+ from prompt_toolkit.validation import ValidationError
9
+ from shvcli import Builtin, Builtins, Client, CliItems, State
10
+ from shvcli.file import copy_file
11
+ from shvcli.tools.complet import comp_from
12
+
13
+
14
+ class BuiltinTimeSync(Builtin):
15
+ """The builtin for setting local time zone."""
16
+
17
+ def __init__(self, builtins: Builtins, state: State) -> None:
18
+ super().__init__(builtins, state)
19
+ builtins["timezone"] = self
20
+
21
+ @property
22
+ def description(self) -> tuple[str, str]: # noqa: D102
23
+ return (
24
+ "[TZ]",
25
+ "Upload the given time zone (or local time zone in default).",
26
+ )
27
+
28
+ def completion( # noqa: PLR6301, D102
29
+ self, items: CliItems, client: Client
30
+ ) -> collections.abc.Iterable[Completion]:
31
+ yield from comp_from(items.param, zoneinfo.available_timezones())
32
+
33
+ def validate(self, items: CliItems, client: Client) -> None: # noqa: D102
34
+ param = items.param
35
+ if param and self._zonefile(items.param) is None:
36
+ raise ValidationError(message=f"No such zoneinfo: {param}")
37
+
38
+ async def run(self, items: CliItems, client: Client) -> None: # noqa: D102
39
+ dest = items.path
40
+ if dest.name != "timeZone":
41
+ dest /= "timeZone"
42
+
43
+ param = items.param
44
+ src = self._zonefile(param) if param else pathlib.Path("/etc/localtime")
45
+ if src is not None:
46
+ await copy_file(client, src, dest)
47
+ else:
48
+ print(f"No such zoneinfo: {param}")
49
+
50
+ @staticmethod
51
+ def _zonefile(param: str) -> pathlib.Path | None:
52
+ for tzpath in map(pathlib.Path, zoneinfo.TZPATH):
53
+ path = tzpath / param
54
+ if path.is_file():
55
+ return path
56
+ return None
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: shvcli-ell
3
+ Version: 0.1.0
4
+ Summary: Silicon Heaven CLI Elektroline extension
5
+ Author: Elektroline a.s.
6
+ Project-URL: source, https://gitlab.com/elektroline-predator/shvcli-ell
7
+ Project-URL: changelog, https://gitlab.com/elektroline-predator/shvcli-ell/-/blob/master/CHANGELOG.md
8
+ Project-URL: issues, https://gitlab.com/elektroline-predator/shvcli-ell/-/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/x-rst
13
+ Requires-Dist: shvcli>=0.7.0
14
+
15
+ Silicon Heaven CLI Elektroline extension
16
+ ========================================
17
+
18
+ The extension for the Silicon Heaven CLI access application to provide utilities
19
+ to work with Elektroline developed SHV systems.
20
+
21
+ * `📃 Sources <https://gitlab.com/elektroline-predator/shvcli-ell>`__
22
+ * `⁉️ Issue tracker <https://gitlab.com/elektroline-predator/shvcli-ell/-/issues>`__
23
+ * `Silicon Heaven CLI <https://gitlab.com/silicon-heaven/shvcli>`__
@@ -0,0 +1,15 @@
1
+ README.rst
2
+ pyproject.toml
3
+ shvcli_ell/__init__.py
4
+ shvcli_ell/__setuptools__.py
5
+ shvcli_ell/__version__.py
6
+ shvcli_ell/plugin.py
7
+ shvcli_ell/py.typed
8
+ shvcli_ell/timesync.py
9
+ shvcli_ell/timezone.py
10
+ shvcli_ell.egg-info/PKG-INFO
11
+ shvcli_ell.egg-info/SOURCES.txt
12
+ shvcli_ell.egg-info/dependency_links.txt
13
+ shvcli_ell.egg-info/entry_points.txt
14
+ shvcli_ell.egg-info/requires.txt
15
+ shvcli_ell.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [shvcli.plugins]
2
+ ell = shvcli_ell.plugin
@@ -0,0 +1 @@
1
+ shvcli>=0.7.0
@@ -0,0 +1 @@
1
+ shvcli_ell