cgse-tools 2024.1.3__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,20 @@
1
+ .python-version
2
+ .envrc
3
+
4
+ build
5
+ dist
6
+
7
+ .DS_Store
8
+
9
+ __pycache__
10
+ .pytest_cache
11
+
12
+ .env
13
+ .venv
14
+ venv
15
+
16
+ .idea
17
+
18
+ **/*.egg-info
19
+
20
+ uv.lock
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: cgse-tools
3
+ Version: 2024.1.3
4
+ Summary: Tools for CGSE
5
+ Author: IVS KU Leuven
6
+ Maintainer-email: Rik Huygen <rik.huygen@kuleuven.be>, Sara Regibo <sara.regibo@kuleuven.be>
7
+ License-Expression: MIT
8
+ Keywords: CGSE,Common-EGSE,hardware testing,software framework
9
+ Requires-Python: >=3.9
10
+ Requires-Dist: cgse-core
11
+ Requires-Dist: rich
12
+ Requires-Dist: textual
13
+ Provides-Extra: dev
14
+ Requires-Dist: pipdeptree; extra == 'dev'
15
+ Requires-Dist: ruff; extra == 'dev'
16
+ Requires-Dist: tomlkit; extra == 'dev'
17
+ Provides-Extra: test
18
+ Requires-Dist: pytest; extra == 'test'
19
+ Requires-Dist: pytest-cov; extra == 'test'
20
+ Requires-Dist: pytest-mock; extra == 'test'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Tools for the CGSE framework
@@ -0,0 +1 @@
1
+ # Tools for the CGSE framework
@@ -0,0 +1,63 @@
1
+ [project]
2
+ name = "cgse-tools"
3
+ version = "2024.1.3"
4
+ description = "Tools for CGSE"
5
+ authors = [
6
+ {name = "IVS KU Leuven"}
7
+ ]
8
+ maintainers = [
9
+ {name = "Rik Huygen", email = "rik.huygen@kuleuven.be"},
10
+ {name = "Sara Regibo", email = "sara.regibo@kuleuven.be"}
11
+ ]
12
+ readme = {"file" = "README.md", "content-type" = "text/markdown"}
13
+ requires-python = ">=3.9"
14
+ license = "MIT"
15
+ keywords = [
16
+ "CGSE",
17
+ "Common-EGSE",
18
+ "hardware testing",
19
+ "software framework"
20
+ ]
21
+ dependencies = [
22
+ "cgse-core",
23
+ "textual",
24
+ "rich",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ test = ["pytest", "pytest-mock", "pytest-cov"]
29
+ dev = ["pipdeptree", "tomlkit", "ruff"]
30
+
31
+ [project.scripts]
32
+ cgse-status = "egse.tools.status:main"
33
+
34
+ [project.entry-points."cgse.version"]
35
+ cgse-tools = 'egse.tools'
36
+
37
+ # Examples of how to provide plugins for the `cgse` command
38
+
39
+ [project.entry-points."cgse.plugins"]
40
+ foo = 'scripts.cgse_plugins:foo'
41
+
42
+ [project.entry-points."cgse.service.plugins"]
43
+ xxx = 'scripts.cgse_service_plugins:xxx'
44
+
45
+ [tool.hatch.build.targets.sdist]
46
+ exclude = [
47
+ "/tests",
48
+ "/pytest.ini",
49
+ "/.gitignore",
50
+ ]
51
+
52
+ [tool.hatch.build.targets.wheel]
53
+ packages = ["src/egse"]
54
+
55
+ [tool.ruff]
56
+ line-length = 120
57
+
58
+ [tool.ruff.lint]
59
+ extend-select = ["E501"]
60
+
61
+ [build-system]
62
+ requires = ["hatchling"]
63
+ build-backend = "hatchling.build"
@@ -0,0 +1,86 @@
1
+ import textwrap
2
+
3
+ import rich
4
+ from rich.text import Text
5
+ from textual.app import App, ComposeResult
6
+ from textual.widgets import Header, Footer
7
+ from textual.widgets import Static, Label
8
+
9
+
10
+ class StatusApp(App):
11
+ """A Textual app to present status information."""
12
+
13
+ BINDINGS = [("d", "toggle_dark", "Toggle dark mode")]
14
+
15
+ def compose(self) -> ComposeResult:
16
+ """Create child widgets for the app."""
17
+ yield Header()
18
+ yield Static(get_log_cs_status())
19
+ yield Static(get_sm_cs_status())
20
+ yield Label(get_cm_cs_status())
21
+ yield Footer()
22
+
23
+ def action_toggle_dark(self) -> None:
24
+ """An action to toggle dark mode."""
25
+ self.dark = not self.dark
26
+
27
+
28
+ def get_log_cs_status():
29
+
30
+ from egse.logger import send_request
31
+
32
+ response = send_request("status")
33
+
34
+ if response.get("status") == "ACK":
35
+ text = textwrap.dedent(
36
+ f"""\
37
+ Log Manager:
38
+ Status: [green]active[/]
39
+ Level [grey50](file)[/]: {response.get('file_logger_level')}
40
+ Level [grey50](stdout)[/]: {response.get('stream_logger_level')}
41
+ Log file location: {response.get('file_logger_location')}
42
+ """
43
+ )
44
+ else:
45
+ text = "Log Manager Status: [red]not active"
46
+
47
+ return text
48
+
49
+
50
+ def get_cm_cs_status():
51
+
52
+ from egse.confman import get_status
53
+ return Text.from_markup(get_status())
54
+
55
+
56
+ def get_sm_cs_status():
57
+
58
+ from egse.storage import get_status
59
+ return Text.from_markup(get_status())
60
+
61
+
62
+ def main():
63
+ from rich import print
64
+
65
+ try:
66
+ # importing 'egse' only will not cause an import error because this package installs
67
+ # 'egse.tools'
68
+ import egse.confman
69
+ import egse.tools
70
+ except ImportError as exc:
71
+ print(
72
+ textwrap.dedent(
73
+ f"""\
74
+ [red]ERROR: Import error on the egse module.[/red] You must have the CGSE package
75
+ installed in the Python environment you are running this tool from.
76
+ """
77
+ ),
78
+ flush=True)
79
+ print(exc)
80
+ return
81
+
82
+ app = StatusApp()
83
+ app.run()
84
+
85
+ if __name__ == "__main__":
86
+ main()
@@ -0,0 +1,9 @@
1
+ # An example plugin for a major command on the `cgse` script in `cgse-core`.
2
+ import click
3
+
4
+
5
+ @click.command()
6
+ @click.option("--full", is_flag=True, help="some option")
7
+ def foo(full: bool = False):
8
+ """Example of major command plugin for `cgse`."""
9
+ print(f"execute foo --{full=}")
@@ -0,0 +1,10 @@
1
+ # An example plugin for the `cgse {start,stop,status} service` command from `cgse-core`.
2
+
3
+ import click
4
+
5
+
6
+ @click.command()
7
+ @click.option("--xxx-plus", is_flag=True, help="some option")
8
+ @click.pass_context
9
+ def xxx(ctx, xxx_plus: bool = False):
10
+ print(f"{ctx.obj['action']} XXX services with {xxx_plus = }")