cgse-tools 2024.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,21 @@
1
+ Metadata-Version: 2.1
2
+ Name: cgse-tools
3
+ Version: 2024.1.0
4
+ Summary: Tools for CGSE
5
+ Author: Rik Huygen
6
+ Author-email: rik.huygen@kuleuven.be
7
+ Requires-Python: >=3.8,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Requires-Dist: cgse-core (==2023.1.0)
16
+ Requires-Dist: rich (>=13.6.0,<14.0.0)
17
+ Requires-Dist: textual
18
+ Description-Content-Type: text/markdown
19
+
20
+ # Tools for the Common-EGSE
21
+
@@ -0,0 +1 @@
1
+ # Tools for the Common-EGSE
@@ -0,0 +1,46 @@
1
+ [tool.poetry]
2
+ name = "cgse-tools"
3
+ version = "2024.1.0"
4
+ description = "Tools for CGSE"
5
+ authors = [
6
+ "Rik Huygen <rik.huygen@kuleuven.be>",
7
+ "Sara Regibo <sara.regibo@kuleuven.be>",
8
+ ]
9
+ readme = "README.md"
10
+ packages = [
11
+ { include = "egse", from = "src" },
12
+ ]
13
+
14
+ [tool.poetry.dependencies]
15
+ python = "^3.8"
16
+ rich = "^13.6.0"
17
+ textual = "*"
18
+
19
+ # The following two lines should be used mutually exclusive. Use the development install of the package when you need
20
+ # the latest source from the repo, when publishing however, the explicit version shall always be used.
21
+ # cgse-core = {path = "../../../libs/cgse-core", develop = true} # this shall be replaced when building
22
+ cgse-core = "2023.1.0"
23
+
24
+ [tool.poetry.group.test.dependencies]
25
+ pytest = "^7.4.2"
26
+ pytest-mock = "^3.11.1"
27
+ pytest-cov = "^4.1.0"
28
+
29
+ [tool.poetry.group.dev.dependencies]
30
+ pipdeptree = "^2.13.0"
31
+ tomlkit = "^0.12.3"
32
+
33
+ [tool.poetry.plugins."cgse.version"]
34
+ cgse-tools = 'egse'
35
+
36
+ # Examples of how to provide plugins for the `cgse` command
37
+
38
+ [tool.poetry.plugins."cgse.plugins"]
39
+ foo = 'scripts.cgse_plugins:foo'
40
+
41
+ [tool.poetry.plugins."cgse.service.plugins"]
42
+ xxx = 'scripts.cgse_service_plugins:xxx'
43
+
44
+ [build-system]
45
+ requires = ["poetry-core"]
46
+ build-backend = "poetry.core.masonry.api"
@@ -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()