cgse-tools 2024.1.0__py3-none-any.whl
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,5 @@
|
|
|
1
|
+
egse/tools/status.py,sha256=2PFjU760X-E2aeLI5sWOZJ_rqHWCG6YwjmqreYpJ6_c,2188
|
|
2
|
+
cgse_tools-2024.1.0.dist-info/METADATA,sha256=-wn2amdc_TBgGgqLby-BJxPFEnioh2rZe8Q74wmEu1I,687
|
|
3
|
+
cgse_tools-2024.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
4
|
+
cgse_tools-2024.1.0.dist-info/entry_points.txt,sha256=iMaeUMKX5BB-5BYndzFSGyPFrmpITs2UtXiAHXzml34,138
|
|
5
|
+
cgse_tools-2024.1.0.dist-info/RECORD,,
|
egse/tools/status.py
ADDED
|
@@ -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()
|