cgse-tools 2025.0.7__py3-none-any.whl → 2025.0.8.dev2__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.
- cgse_tools/__init__.py +0 -0
- cgse_tools/cgse_commands.py +106 -0
- cgse_tools/cgse_services.py +28 -0
- {cgse_tools-2025.0.7.dist-info → cgse_tools-2025.0.8.dev2.dist-info}/METADATA +1 -1
- cgse_tools-2025.0.8.dev2.dist-info/RECORD +8 -0
- cgse_tools-2025.0.8.dev2.dist-info/entry_points.txt +11 -0
- cgse_tools-2025.0.7.dist-info/RECORD +0 -5
- cgse_tools-2025.0.7.dist-info/entry_points.txt +0 -11
- {cgse_tools-2025.0.7.dist-info → cgse_tools-2025.0.8.dev2.dist-info}/WHEEL +0 -0
cgse_tools/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import subprocess
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Annotated
|
|
6
|
+
|
|
7
|
+
import rich
|
|
8
|
+
import typer
|
|
9
|
+
|
|
10
|
+
app = typer.Typer()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.command()
|
|
14
|
+
def top():
|
|
15
|
+
"""
|
|
16
|
+
A top-like interface for core services and device control servers.
|
|
17
|
+
|
|
18
|
+
Not yet implemented.
|
|
19
|
+
"""
|
|
20
|
+
print("This fancy top is not yet implemented.")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
show = typer.Typer(help="Show information about settings, environment, setup, ...", no_args_is_help=True)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@show.command(name="settings")
|
|
27
|
+
def show_settings():
|
|
28
|
+
proc = subprocess.Popen(
|
|
29
|
+
[sys.executable, "-m", "egse.settings"],
|
|
30
|
+
stdout=subprocess.PIPE,
|
|
31
|
+
stderr=subprocess.PIPE
|
|
32
|
+
)
|
|
33
|
+
stdout, stderr = proc.communicate()
|
|
34
|
+
rich.print(stdout.decode(), end='')
|
|
35
|
+
if stderr:
|
|
36
|
+
rich.print(f"[red]{stderr.decode()}[/]")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@show.command(name="env")
|
|
40
|
+
def show_env(
|
|
41
|
+
mkdir: Annotated[bool, typer.Option(help="Create the missing folder")] = None,
|
|
42
|
+
full: Annotated[bool, typer.Option(help="Provide additional info")] = None,
|
|
43
|
+
doc: Annotated[bool, typer.Option(help="Provide documentation on environment variables")] = None,
|
|
44
|
+
):
|
|
45
|
+
options = [opt for opt, flag in [("--mkdir", mkdir), ("--full", full), ("--doc", doc)] if flag]
|
|
46
|
+
|
|
47
|
+
cmd = [sys.executable, "-m", "egse.env"]
|
|
48
|
+
cmd += options if options else []
|
|
49
|
+
|
|
50
|
+
proc = subprocess.Popen(
|
|
51
|
+
cmd,
|
|
52
|
+
stdout=subprocess.PIPE,
|
|
53
|
+
stderr=subprocess.PIPE
|
|
54
|
+
)
|
|
55
|
+
stdout, stderr = proc.communicate()
|
|
56
|
+
rich.print(stdout.decode(), end='')
|
|
57
|
+
if stderr:
|
|
58
|
+
rich.print(f"[red]{stderr.decode()}[/]")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
check = typer.Typer(help="Check installation, settings, required files, etc.", no_args_is_help=True)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@check.command(name="setups")
|
|
65
|
+
def check_setups():
|
|
66
|
+
"""Perform a number of checks on the SETUP files."""
|
|
67
|
+
|
|
68
|
+
# What can we check with respect to the setups?
|
|
69
|
+
#
|
|
70
|
+
# - CONF_DATA_LOCATION
|
|
71
|
+
|
|
72
|
+
from egse.env import get_conf_data_location
|
|
73
|
+
from egse.env import get_site_id
|
|
74
|
+
from egse.config import find_files
|
|
75
|
+
|
|
76
|
+
any_errors = 0
|
|
77
|
+
|
|
78
|
+
conf_data_location = get_conf_data_location()
|
|
79
|
+
site_id = get_site_id()
|
|
80
|
+
|
|
81
|
+
# ---------- check if the <PROJECT>_CONF_DATA_LOCATION is set
|
|
82
|
+
|
|
83
|
+
if not conf_data_location:
|
|
84
|
+
any_errors += 1
|
|
85
|
+
rich.print("[red]The location of the configuration data can not be determined, check your environment.[/]")
|
|
86
|
+
|
|
87
|
+
if not Path(conf_data_location).exists():
|
|
88
|
+
any_errors += 1
|
|
89
|
+
rich.print(f"[red]The location of the configuration data doesn't exist: {conf_data_location!s}[/]")
|
|
90
|
+
|
|
91
|
+
# ---------- check if there is at least one SETUP in the configuration data folder
|
|
92
|
+
|
|
93
|
+
files = list(find_files("SETUP*.yaml", root=conf_data_location))
|
|
94
|
+
|
|
95
|
+
if not files:
|
|
96
|
+
any_errors += 1
|
|
97
|
+
rich.print(f"[red]No SETUP files were found at {conf_data_location}[/]")
|
|
98
|
+
|
|
99
|
+
regex = re.compile(f"SETUP_{site_id}_00000_.*.yaml")
|
|
100
|
+
|
|
101
|
+
if not any(True for file in files if regex.search(str(file))):
|
|
102
|
+
any_errors += 1
|
|
103
|
+
rich.print(f"[red]The is no Zero SETUP for {site_id} in {conf_data_location}[/]")
|
|
104
|
+
|
|
105
|
+
if not any_errors:
|
|
106
|
+
rich.print("[green]everything seems to be ok.[/]")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# An example plugin for the `cgse {start,stop,status} service` command from `cgse-core`.
|
|
2
|
+
#
|
|
3
|
+
import rich
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
dev_x = typer.Typer(
|
|
7
|
+
name="dev-x",
|
|
8
|
+
help="device-x is an imaginary device that serves as an example",
|
|
9
|
+
no_args_is_help=True
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dev_x.command(name="start")
|
|
14
|
+
def start_dev_x():
|
|
15
|
+
"""Start the dev-x service."""
|
|
16
|
+
rich.print("Starting service dev_x")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dev_x.command(name="stop")
|
|
20
|
+
def stop_dev_x():
|
|
21
|
+
"""Stop the dev-x service."""
|
|
22
|
+
rich.print("Terminating service dev_x")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dev_x.command(name="status")
|
|
26
|
+
def status_dev_x():
|
|
27
|
+
"""Print status information on the dev-x service."""
|
|
28
|
+
rich.print("Printing the status of dev_x")
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
cgse_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
cgse_tools/cgse_commands.py,sha256=Vh9veF8rh3hCzv6try_T7Jzv-u_z4-8qGJ3w81ZQ3NM,3093
|
|
3
|
+
cgse_tools/cgse_services.py,sha256=ZERds5uCHuR5_R4YpBkc2yUTGImtVdKlItherlfL5IM,661
|
|
4
|
+
egse/tools/status.py,sha256=2PFjU760X-E2aeLI5sWOZJ_rqHWCG6YwjmqreYpJ6_c,2188
|
|
5
|
+
cgse_tools-2025.0.8.dev2.dist-info/METADATA,sha256=BOt9sEs2HhDn6dVjFGNsbfEzMknD-8kC1RIYbPW7AIc,613
|
|
6
|
+
cgse_tools-2025.0.8.dev2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
cgse_tools-2025.0.8.dev2.dist-info/entry_points.txt,sha256=JY7rD8p4H2_MS_4Al0KNsdB5s9uCEawa8NE4pMKlcfc,290
|
|
8
|
+
cgse_tools-2025.0.8.dev2.dist-info/RECORD,,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
cgse-status = egse.tools.status:main
|
|
3
|
+
|
|
4
|
+
[cgse.command.plugins]
|
|
5
|
+
check = cgse_tools.cgse_commands:check[group]
|
|
6
|
+
dev-x = cgse_tools.cgse_services:dev_x[group]
|
|
7
|
+
show = cgse_tools.cgse_commands:show[group]
|
|
8
|
+
top = cgse_tools.cgse_commands:top
|
|
9
|
+
|
|
10
|
+
[cgse.version]
|
|
11
|
+
cgse-tools = egse.tools
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
egse/tools/status.py,sha256=2PFjU760X-E2aeLI5sWOZJ_rqHWCG6YwjmqreYpJ6_c,2188
|
|
2
|
-
cgse_tools-2025.0.7.dist-info/METADATA,sha256=Rw270gskIlSkTbB-arsBIvdUcjtOrncVYpJ3OHH1gdU,608
|
|
3
|
-
cgse_tools-2025.0.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
4
|
-
cgse_tools-2025.0.7.dist-info/entry_points.txt,sha256=aRWmsZlFmI7l8gzByyUwcVTvxVYce-QxUkegSfB1yvo,205
|
|
5
|
-
cgse_tools-2025.0.7.dist-info/RECORD,,
|
|
File without changes
|