cgse-core 2025.0.4__py3-none-any.whl → 2025.0.5__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_core-2025.0.4.dist-info → cgse_core-2025.0.5.dist-info}/METADATA +1 -5
- {cgse_core-2025.0.4.dist-info → cgse_core-2025.0.5.dist-info}/RECORD +11 -10
- egse/confman/__init__.py +47 -26
- egse/confman/confman_cs.py +7 -10
- egse/logger/log_cs.py +2 -2
- egse/procman/__init__.py +7 -2
- egse/settings.yaml +32 -0
- egse/storage/__init__.py +12 -11
- egse/storage/storage_cs.py +4 -4
- {cgse_core-2025.0.4.dist-info → cgse_core-2025.0.5.dist-info}/WHEEL +0 -0
- {cgse_core-2025.0.4.dist-info → cgse_core-2025.0.5.dist-info}/entry_points.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cgse-core
|
|
3
|
-
Version: 2025.0.
|
|
3
|
+
Version: 2025.0.5
|
|
4
4
|
Summary: Core services for the CGSE framework
|
|
5
5
|
Author-email: Rik Huygen <rik.huygen@kuleuven.be>, Sara Regibo <sara.regibo@kuleuven.be>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -13,10 +13,6 @@ Requires-Dist: gitpython>=3.1.44
|
|
|
13
13
|
Requires-Dist: prometheus-client>=0.21.1
|
|
14
14
|
Requires-Dist: pyzmq==23.2.1
|
|
15
15
|
Requires-Dist: rich>=13.9.4
|
|
16
|
-
Provides-Extra: dev
|
|
17
|
-
Requires-Dist: pytest; extra == 'dev'
|
|
18
|
-
Requires-Dist: pytest-cov; extra == 'dev'
|
|
19
|
-
Requires-Dist: pytest-mock; extra == 'dev'
|
|
20
16
|
Description-Content-Type: text/markdown
|
|
21
17
|
|
|
22
18
|
# The core services for the CGSE platform
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
egse/
|
|
1
|
+
egse/settings.yaml,sha256=OtloyzII85CFJ1mG00QrRts7jtWAMHBOeXBb0QVc9kY,2663
|
|
2
|
+
egse/confman/__init__.py,sha256=Woeffl3sRL-r3tfEgbtCSwZBd2GnctSt0zxULeE10c8,37831
|
|
2
3
|
egse/confman/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
4
|
egse/confman/confman.yaml,sha256=V3TnUHEVlrHt2VZ1HFOGgRVjq_fhWAIAg5eslKddMEs,2909
|
|
4
|
-
egse/confman/confman_cs.py,sha256=
|
|
5
|
+
egse/confman/confman_cs.py,sha256=Yyhj0tvG0zQEEcsWZgPCsAW3-MDKL-9nAqXkFhVkoR4,6404
|
|
5
6
|
egse/logger/__init__.py,sha256=lkwftajGyfsUQe-iwi0IDU9w5rsIirdZPqAataKC3rU,8163
|
|
6
7
|
egse/logger/__main__.py,sha256=RFCl0vmeNmHeXNDbziUP5sDwC014TqwJfc8xtDvZ_as,370
|
|
7
|
-
egse/logger/log_cs.py,sha256=
|
|
8
|
-
egse/procman/__init__.py,sha256=
|
|
8
|
+
egse/logger/log_cs.py,sha256=lFZe5z5U_k28L3qp3P1rQt1Ux0OxM3pLdNXIvKSiF9s,9303
|
|
9
|
+
egse/procman/__init__.py,sha256=VJ0gkBC7U2LkwKY_JpL7_--7kQHWdVYbNgHB_FhRjog,27494
|
|
9
10
|
egse/procman/procman.yaml,sha256=ig7SKFAh3gif2EUhSLAA39sdbPf66LfduJ2OcInxNYU,1608
|
|
10
11
|
egse/procman/procman_cs.py,sha256=Ht2xQA36-K2yUNA0ac0HIBopnZv0X8oSIz5HaAqPeKI,6001
|
|
11
|
-
egse/storage/__init__.py,sha256=
|
|
12
|
+
egse/storage/__init__.py,sha256=m-ooUTD6_WBssSDMAYPIBgWph2YEpf6abvxghnbd49c,40013
|
|
12
13
|
egse/storage/__main__.py,sha256=LI9fxlsFWmEd5LcWUB0xA8i7Yt6UHgnblB4G0aTi3pI,28
|
|
13
14
|
egse/storage/persistence.py,sha256=e4kMTszUXQxqPWBfnA_3elRHaKQmXJvKri7LwXQZXdk,18246
|
|
14
15
|
egse/storage/storage.yaml,sha256=zTRtRFbuMLBILsnlIphG6iWjI1Nav6tW7uOm4cUvFuk,2593
|
|
15
|
-
egse/storage/storage_cs.py,sha256=
|
|
16
|
+
egse/storage/storage_cs.py,sha256=Z-HnpeqF5QgRLjhEnW4jIQ6QKFdY55jK1XBUttxww_k,5447
|
|
16
17
|
scripts/cgse.py,sha256=euz9Lw3Lh0X-DZct7jywTX6JQJPiBua_zIRhsERI-64,5182
|
|
17
|
-
cgse_core-2025.0.
|
|
18
|
-
cgse_core-2025.0.
|
|
19
|
-
cgse_core-2025.0.
|
|
20
|
-
cgse_core-2025.0.
|
|
18
|
+
cgse_core-2025.0.5.dist-info/METADATA,sha256=Q2WzcHoPQp3LOA2p5n51zlvvrXG4WltGK142K2xEAUg,605
|
|
19
|
+
cgse_core-2025.0.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
20
|
+
cgse_core-2025.0.5.dist-info/entry_points.txt,sha256=gcg5ck-Lh7byq1S88agmzwxFG5OJBsIDH439gaUPkHE,215
|
|
21
|
+
cgse_core-2025.0.5.dist-info/RECORD,,
|
egse/confman/__init__.py
CHANGED
|
@@ -128,18 +128,21 @@ from egse.command import ClientServerCommand
|
|
|
128
128
|
from egse.command import stringify_function_call
|
|
129
129
|
from egse.config import find_file
|
|
130
130
|
from egse.config import find_files
|
|
131
|
-
from egse.config import get_common_egse_root
|
|
132
131
|
from egse.control import ControlServer
|
|
133
|
-
from egse.control import Failure
|
|
134
|
-
from egse.control import Response
|
|
135
|
-
from egse.control import Success
|
|
136
132
|
from egse.control import is_control_server_active
|
|
137
133
|
from egse.decorators import dynamic_interface
|
|
138
134
|
from egse.decorators import static_vars
|
|
135
|
+
from egse.env import get_conf_data_location
|
|
136
|
+
from egse.env import get_conf_repo_location
|
|
137
|
+
from egse.env import get_project_name
|
|
138
|
+
from egse.env import get_site_id
|
|
139
139
|
from egse.exceptions import InternalError
|
|
140
140
|
from egse.obsid import ObservationIdentifier
|
|
141
141
|
from egse.protocol import CommandProtocol
|
|
142
142
|
from egse.proxy import Proxy
|
|
143
|
+
from egse.response import Failure
|
|
144
|
+
from egse.response import Response
|
|
145
|
+
from egse.response import Success
|
|
143
146
|
from egse.settings import Settings
|
|
144
147
|
from egse.settings import SettingsError
|
|
145
148
|
from egse.setup import Setup
|
|
@@ -147,17 +150,17 @@ from egse.setup import load_last_setup_id
|
|
|
147
150
|
from egse.setup import save_last_setup_id
|
|
148
151
|
from egse.system import filter_by_attr
|
|
149
152
|
from egse.system import format_datetime
|
|
150
|
-
from egse.system import replace_environment_variable
|
|
151
153
|
from egse.version import VERSION
|
|
152
154
|
from egse.zmq_ser import bind_address
|
|
153
155
|
from egse.zmq_ser import connect_address
|
|
154
156
|
|
|
155
157
|
LOGGER = logging.getLogger(__name__)
|
|
156
158
|
|
|
159
|
+
HERE = Path(__file__).parent
|
|
160
|
+
|
|
157
161
|
CTRL_SETTINGS = Settings.load("Configuration Manager Control Server")
|
|
158
|
-
|
|
159
|
-
COMMAND_SETTINGS = Settings.load(filename="confman.yaml")
|
|
160
|
-
REPO = Settings.load("REPO")
|
|
162
|
+
SITE_ID = get_site_id()
|
|
163
|
+
COMMAND_SETTINGS = Settings.load(location=HERE, filename="confman.yaml")
|
|
161
164
|
|
|
162
165
|
CM_SETUP_ID = Gauge("CM_SETUP_ID", 'Setup ID')
|
|
163
166
|
CM_TEST_ID = Gauge("CM_TEST_ID", 'Test ID')
|
|
@@ -174,14 +177,14 @@ def _push_setup_to_repo(filename: str, commit_msg: str) -> Failure | Success:
|
|
|
174
177
|
None.
|
|
175
178
|
"""
|
|
176
179
|
|
|
177
|
-
repo_workdir =
|
|
178
|
-
|
|
180
|
+
repo_workdir = get_conf_repo_location()
|
|
181
|
+
|
|
179
182
|
if repo_workdir is None:
|
|
180
183
|
msg = textwrap.dedent(
|
|
181
|
-
"""\
|
|
182
|
-
Couldn't determine the repository location for
|
|
184
|
+
f"""\
|
|
185
|
+
Couldn't determine the repository location for configuration data.
|
|
183
186
|
|
|
184
|
-
Check if the environment variable '
|
|
187
|
+
Check if the environment variable '{get_project_name()}_CONF_REPO_LOCATION' is set and valid
|
|
185
188
|
before starting the configuration manager.
|
|
186
189
|
"""
|
|
187
190
|
)
|
|
@@ -285,8 +288,14 @@ def _populate_cached_setup_info():
|
|
|
285
288
|
|
|
286
289
|
LOGGER.info("Populating cache with Setup Info.")
|
|
287
290
|
|
|
288
|
-
location =
|
|
289
|
-
|
|
291
|
+
location = get_conf_data_location()
|
|
292
|
+
if location:
|
|
293
|
+
data_conf_location = Path(location)
|
|
294
|
+
else:
|
|
295
|
+
raise ValueError(
|
|
296
|
+
"Couldn't determine location of the configuration data with 'get_conf_data_location()'. "
|
|
297
|
+
"Check if the environment is properly defined."
|
|
298
|
+
)
|
|
290
299
|
|
|
291
300
|
setup_info = {}
|
|
292
301
|
|
|
@@ -550,8 +559,13 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
550
559
|
|
|
551
560
|
# Find the location for the configuration data
|
|
552
561
|
|
|
553
|
-
location =
|
|
554
|
-
|
|
562
|
+
location = get_conf_data_location()
|
|
563
|
+
if location:
|
|
564
|
+
self._data_conf_location = Path(location)
|
|
565
|
+
else:
|
|
566
|
+
raise ValueError(
|
|
567
|
+
"The location for the configuration data is not defined. Please check your environment."
|
|
568
|
+
)
|
|
555
569
|
|
|
556
570
|
# Populate the cache with information from the available Setups. This will also load each
|
|
557
571
|
# Setup and cache them with the lru_cache decorator. Since this takes about 5s for 100
|
|
@@ -590,7 +604,7 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
590
604
|
last_obsid = self._storage.read({"origin": "obsid", "select": "last_line"})
|
|
591
605
|
last_obsid = last_obsid.return_code if isinstance(last_obsid, Success) else None
|
|
592
606
|
|
|
593
|
-
self._obsid = create_obsid(last_obsid,
|
|
607
|
+
self._obsid = create_obsid(last_obsid, SITE_ID, self._setup_id)
|
|
594
608
|
|
|
595
609
|
if self._storage:
|
|
596
610
|
response = self._storage.start_observation(self._obsid, self._sut_name)
|
|
@@ -696,14 +710,14 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
696
710
|
|
|
697
711
|
setup_files = list(
|
|
698
712
|
find_files(
|
|
699
|
-
pattern=f"SETUP_{
|
|
713
|
+
pattern=f"SETUP_{SITE_ID}_{setup_id:05d}_*.yaml", root=self._data_conf_location
|
|
700
714
|
)
|
|
701
715
|
)
|
|
702
716
|
|
|
703
717
|
if len(setup_files) != 1:
|
|
704
718
|
LOGGER.error(
|
|
705
719
|
msg := f"Expected to find just one Setup YAML file, found {len(setup_files)}. "
|
|
706
|
-
f"[{
|
|
720
|
+
f"[{SITE_ID = }, {setup_id = }, data_conf_location={self._data_conf_location}]"
|
|
707
721
|
)
|
|
708
722
|
return Failure("Loading Setup", InternalError(msg))
|
|
709
723
|
|
|
@@ -745,7 +759,7 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
745
759
|
|
|
746
760
|
setup_files = list(
|
|
747
761
|
find_files(
|
|
748
|
-
pattern=f"SETUP_{
|
|
762
|
+
pattern=f"SETUP_{SITE_ID}_{setup_id:05d}_*.yaml", root=self._data_conf_location
|
|
749
763
|
)
|
|
750
764
|
)
|
|
751
765
|
|
|
@@ -786,7 +800,7 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
786
800
|
The Site identifier as a string.
|
|
787
801
|
"""
|
|
788
802
|
|
|
789
|
-
return
|
|
803
|
+
return SITE_ID
|
|
790
804
|
|
|
791
805
|
def reload_setups(self):
|
|
792
806
|
"""
|
|
@@ -839,7 +853,7 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
839
853
|
try:
|
|
840
854
|
setup_id = int(rc.return_code[-1].split(maxsplit=3)[2])
|
|
841
855
|
setup_file = find_file(
|
|
842
|
-
name=f"SETUP_{
|
|
856
|
+
name=f"SETUP_{SITE_ID}_{setup_id:05d}_*.yaml", root=self._data_conf_location
|
|
843
857
|
)
|
|
844
858
|
setup = Setup.from_yaml_file(setup_file)
|
|
845
859
|
except (IndexError, SettingsError):
|
|
@@ -867,7 +881,7 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
867
881
|
|
|
868
882
|
setup_id = self.get_next_setup_id_for_site(site)
|
|
869
883
|
|
|
870
|
-
filename = _construct_filename(
|
|
884
|
+
filename = _construct_filename(SITE_ID, setup_id)
|
|
871
885
|
|
|
872
886
|
if not hasattr(setup, "history"):
|
|
873
887
|
setup.history = {}
|
|
@@ -876,6 +890,12 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
876
890
|
setup.set_private_attribute("_setup_id", setup_id)
|
|
877
891
|
setup.to_yaml_file(self._data_conf_location / filename)
|
|
878
892
|
|
|
893
|
+
# No repository is defined. This should not break, but a warning is in place.
|
|
894
|
+
# The warnings are issued by the get_conf_repo_location() function.
|
|
895
|
+
|
|
896
|
+
if get_conf_repo_location() is None:
|
|
897
|
+
return
|
|
898
|
+
|
|
879
899
|
try:
|
|
880
900
|
rc = _push_setup_to_repo(filename, description)
|
|
881
901
|
if isinstance(rc, Failure):
|
|
@@ -896,12 +916,13 @@ class ConfigurationManagerController(ConfigurationManagerInterface):
|
|
|
896
916
|
return setup
|
|
897
917
|
|
|
898
918
|
def get_next_setup_id_for_site(self, site: str) -> int:
|
|
899
|
-
"""
|
|
919
|
+
"""
|
|
920
|
+
Return the next available Setup ID for the given Site.
|
|
900
921
|
|
|
901
922
|
Args:
|
|
902
923
|
site (str): site identification, e.g. CSL, SRON, ...
|
|
903
924
|
"""
|
|
904
|
-
site = site or
|
|
925
|
+
site = site or SITE_ID
|
|
905
926
|
files = sorted(find_files(pattern=f"SETUP_{site}_*.yaml", root=self._data_conf_location))
|
|
906
927
|
last_file = files[-1]
|
|
907
928
|
setup_id = last_file.name.split("_")[2]
|
egse/confman/confman_cs.py
CHANGED
|
@@ -16,15 +16,15 @@ from pathlib import Path
|
|
|
16
16
|
import click
|
|
17
17
|
import rich
|
|
18
18
|
import zmq
|
|
19
|
-
from egse.control import ControlServer
|
|
20
|
-
from egse.control import Response
|
|
21
|
-
from egse.process import SubProcess
|
|
22
|
-
from egse.settings import Settings
|
|
23
|
-
from egse.system import replace_environment_variable
|
|
24
19
|
from prometheus_client import start_http_server
|
|
25
20
|
|
|
26
21
|
from egse.confman import ConfigurationManagerProtocol
|
|
27
22
|
from egse.confman import ConfigurationManagerProxy
|
|
23
|
+
from egse.control import ControlServer
|
|
24
|
+
from egse.env import get_conf_data_location
|
|
25
|
+
from egse.process import SubProcess
|
|
26
|
+
from egse.response import Response
|
|
27
|
+
from egse.settings import Settings
|
|
28
28
|
|
|
29
29
|
# Use explicit name here otherwise the logger will probably be called __main__
|
|
30
30
|
|
|
@@ -205,14 +205,11 @@ def check_prerequisites():
|
|
|
205
205
|
|
|
206
206
|
# We need a proper location for storing the configuration data.
|
|
207
207
|
|
|
208
|
-
location =
|
|
209
|
-
location = replace_environment_variable(location)
|
|
208
|
+
location = get_conf_data_location()
|
|
210
209
|
|
|
211
210
|
if not location:
|
|
212
211
|
raise RuntimeError(
|
|
213
|
-
"The
|
|
214
|
-
"FILE_STORAGE_LOCATION of the Configuration Manager does not exist, please set "
|
|
215
|
-
"the environment variable."
|
|
212
|
+
"The location for the configuration data is not defined. Please check your environment."
|
|
216
213
|
)
|
|
217
214
|
|
|
218
215
|
location = Path(location)
|
egse/logger/log_cs.py
CHANGED
|
@@ -119,9 +119,9 @@ def start():
|
|
|
119
119
|
stream_handler = StreamHandler()
|
|
120
120
|
stream_handler.setFormatter(logging.Formatter(fmt=LOG_FORMAT_STREAM))
|
|
121
121
|
|
|
122
|
-
# Log records are also sent to the
|
|
122
|
+
# Log records are also sent to the textualog listening server
|
|
123
123
|
|
|
124
|
-
socket_handler = SocketHandler(CTRL_SETTINGS.
|
|
124
|
+
socket_handler = SocketHandler(CTRL_SETTINGS.TEXTUALOG_IP_ADDRESS, CTRL_SETTINGS.TEXTUALOG_LISTENING_PORT)
|
|
125
125
|
socket_handler.setFormatter(file_formatter)
|
|
126
126
|
|
|
127
127
|
context = zmq.Context()
|
egse/procman/__init__.py
CHANGED
|
@@ -7,11 +7,14 @@ import pickle
|
|
|
7
7
|
import time
|
|
8
8
|
|
|
9
9
|
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
10
12
|
import zmq
|
|
11
13
|
|
|
12
14
|
from egse.command import ClientServerCommand
|
|
13
15
|
from egse.confman import ConfigurationManagerProxy
|
|
14
|
-
from egse.control import ControlServer
|
|
16
|
+
from egse.control import ControlServer
|
|
17
|
+
from egse.response import Success, Failure
|
|
15
18
|
from egse.decorators import dynamic_interface
|
|
16
19
|
from egse.dpu import fitsgen
|
|
17
20
|
from egse.dpu.dpu_cs import is_dpu_cs_active
|
|
@@ -29,8 +32,10 @@ from egse.system import format_datetime
|
|
|
29
32
|
from egse.zmq_ser import bind_address
|
|
30
33
|
from egse.zmq_ser import connect_address
|
|
31
34
|
|
|
35
|
+
HERE = Path(__file__).parent
|
|
36
|
+
|
|
32
37
|
CTRL_SETTINGS = Settings.load("Process Manager Control Server")
|
|
33
|
-
COMMAND_SETTINGS = Settings.load(filename="procman.yaml")
|
|
38
|
+
COMMAND_SETTINGS = Settings.load(location=HERE, filename="procman.yaml")
|
|
34
39
|
|
|
35
40
|
LOGGER = logging.getLogger(__name__)
|
|
36
41
|
|
egse/settings.yaml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Logging Control Server: # LOG_CS
|
|
2
|
+
|
|
3
|
+
PROTOCOL: tcp
|
|
4
|
+
HOSTNAME: localhost # The hostname that client shall connect to, e.g. pleiad01 @ KU Leuven
|
|
5
|
+
LOGGING_PORT: 7000
|
|
6
|
+
COMMANDING_PORT: 7001
|
|
7
|
+
METRICS_PORT: 7003 # The HTTP port where Prometheus will connect to for retrieving metrics
|
|
8
|
+
MAX_NR_LOG_FILES: 20 # The maximum number of log files that will be maintained in a roll-over
|
|
9
|
+
MAX_SIZE_LOG_FILES: 20 # The maximum size one log file can become
|
|
10
|
+
TEXTUALOG_IP_ADDRESS: 127.0.0.1 # The IP address of the textualog listening server
|
|
11
|
+
TEXTUALOG_LISTENING_PORT: 19996 # The port number on which the textualog server is listening
|
|
12
|
+
|
|
13
|
+
Configuration Manager Control Server: # CM_CS
|
|
14
|
+
|
|
15
|
+
PROTOCOL: tcp
|
|
16
|
+
HOSTNAME: localhost # The hostname that client shall connect to, e.g. pleiad01 @ KU Leuven
|
|
17
|
+
COMMANDING_PORT: 6000 # The port on which the controller listens to commands - REQ-REP
|
|
18
|
+
MONITORING_PORT: 6001 # The port on which the controller sends periodic status information of the device - PUB-SUB
|
|
19
|
+
SERVICE_PORT: 6002 # The port on which the controller listens for configuration and administration - REQ-REP
|
|
20
|
+
METRICS_PORT: 6003 # The HTTP port where Prometheus will connect to for retrieving metrics
|
|
21
|
+
DELAY: 1 # The delay time between publishing status information [seconds]
|
|
22
|
+
STORAGE_MNEMONIC: CM # The mnemonic to be used in the filename storing the housekeeping data
|
|
23
|
+
|
|
24
|
+
Storage Control Server: # SM_CS
|
|
25
|
+
|
|
26
|
+
PROTOCOL: tcp
|
|
27
|
+
HOSTNAME: localhost # The hostname that client shall connect to, e.g. pleiad01 @ KU Leuven
|
|
28
|
+
COMMANDING_PORT: 6100 # The port on which the controller listens to commands - REQ-REP
|
|
29
|
+
MONITORING_PORT: 6101 # The port on which the controller sends periodic status information of the device - PUB-SUB
|
|
30
|
+
SERVICE_PORT: 6102 # The port on which the controller listens for configuration and administration - REQ-REP
|
|
31
|
+
METRICS_PORT: 6103 # The HTTP port where Prometheus will connect to for retrieving metrics
|
|
32
|
+
DELAY: 1 # The delay time between publishing status information [seconds]
|
egse/storage/__init__.py
CHANGED
|
@@ -112,9 +112,10 @@ from egse.bits import humanize_bytes
|
|
|
112
112
|
from egse.command import ClientServerCommand
|
|
113
113
|
from egse.config import find_files
|
|
114
114
|
from egse.control import ControlServer
|
|
115
|
-
from egse.
|
|
116
|
-
from egse.
|
|
117
|
-
from egse.
|
|
115
|
+
from egse.env import get_site_id
|
|
116
|
+
from egse.response import Failure
|
|
117
|
+
from egse.response import Response
|
|
118
|
+
from egse.response import Success
|
|
118
119
|
from egse.control import is_control_server_active
|
|
119
120
|
from egse.decorators import dynamic_interface
|
|
120
121
|
from egse.env import get_data_storage_location
|
|
@@ -132,11 +133,11 @@ from egse.zmq_ser import connect_address
|
|
|
132
133
|
|
|
133
134
|
logger = logging.getLogger(__name__)
|
|
134
135
|
|
|
136
|
+
HERE = Path(__file__).parent
|
|
137
|
+
|
|
135
138
|
CTRL_SETTINGS = Settings.load("Storage Control Server")
|
|
136
|
-
|
|
137
|
-
COMMAND_SETTINGS = Settings.load(filename="storage.yaml")
|
|
138
|
-
DEVICE_SETTINGS = Settings.load(filename="storage.yaml")
|
|
139
|
-
CCD_SETTINGS = Settings.load("CCD")
|
|
139
|
+
SITE_ID = get_site_id()
|
|
140
|
+
DEVICE_SETTINGS = COMMAND_SETTINGS = Settings.load(location=HERE, filename="storage.yaml")
|
|
140
141
|
|
|
141
142
|
__all__ = [
|
|
142
143
|
"is_storage_manager_active",
|
|
@@ -543,7 +544,7 @@ def _construct_filename(
|
|
|
543
544
|
The full path to the file as a `PurePath`.
|
|
544
545
|
"""
|
|
545
546
|
|
|
546
|
-
site_id = site_id or
|
|
547
|
+
site_id = site_id or SITE_ID
|
|
547
548
|
location = location or get_data_storage_location(site_id=site_id)
|
|
548
549
|
|
|
549
550
|
if obsid:
|
|
@@ -854,7 +855,7 @@ class StorageController(StorageInterface):
|
|
|
854
855
|
self._registry.register(item["origin"], item)
|
|
855
856
|
|
|
856
857
|
if "filename" in item:
|
|
857
|
-
location = Path(get_data_storage_location(site_id=
|
|
858
|
+
location = Path(get_data_storage_location(site_id=SITE_ID))
|
|
858
859
|
filename = location / item["filename"]
|
|
859
860
|
else:
|
|
860
861
|
filename = _construct_filename(item["origin"], item["persistence_class"].extension,
|
|
@@ -972,7 +973,7 @@ class StorageController(StorageInterface):
|
|
|
972
973
|
)
|
|
973
974
|
|
|
974
975
|
def get_storage_location(self):
|
|
975
|
-
return get_data_storage_location(site_id=
|
|
976
|
+
return get_data_storage_location(site_id=SITE_ID)
|
|
976
977
|
|
|
977
978
|
def get_filenames(self, item: dict) -> List[Path]:
|
|
978
979
|
registered_item = self._registry.get(item["origin"])
|
|
@@ -995,7 +996,7 @@ class StorageController(StorageInterface):
|
|
|
995
996
|
|
|
996
997
|
def get_disk_usage(self):
|
|
997
998
|
|
|
998
|
-
location = Path(get_data_storage_location(site_id=
|
|
999
|
+
location = Path(get_data_storage_location(site_id=SITE_ID))
|
|
999
1000
|
total, used, free = shutil.disk_usage(location)
|
|
1000
1001
|
return total, used, free
|
|
1001
1002
|
|
egse/storage/storage_cs.py
CHANGED
|
@@ -20,6 +20,7 @@ from pytz import utc
|
|
|
20
20
|
from egse.bits import humanize_bytes
|
|
21
21
|
from egse.control import ControlServer
|
|
22
22
|
from egse.env import get_data_storage_location
|
|
23
|
+
from egse.env import get_site_id
|
|
23
24
|
from egse.process import SubProcess
|
|
24
25
|
from egse.settings import Settings
|
|
25
26
|
from egse.storage import StorageProtocol
|
|
@@ -33,7 +34,7 @@ from egse.system import replace_environment_variable
|
|
|
33
34
|
logger = logging.getLogger("egse.storage.storage_cs")
|
|
34
35
|
|
|
35
36
|
CTRL_SETTINGS = Settings.load("Storage Control Server")
|
|
36
|
-
|
|
37
|
+
SITE_ID = get_site_id()
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
class StorageControlServer(ControlServer):
|
|
@@ -159,12 +160,11 @@ def check_prerequisites():
|
|
|
159
160
|
# We need a proper location for storing the data, this directory shall contain
|
|
160
161
|
# two subfolders: 'daily' and 'obs'.
|
|
161
162
|
|
|
162
|
-
location = get_data_storage_location(site_id=
|
|
163
|
+
location = get_data_storage_location(site_id=SITE_ID)
|
|
163
164
|
|
|
164
165
|
if not location:
|
|
165
166
|
raise RuntimeError(
|
|
166
|
-
"The
|
|
167
|
-
"FILE_STORAGE_LOCATION does not exist, please set the environment variable."
|
|
167
|
+
"The data storage location is not defined. Please check your environment."
|
|
168
168
|
)
|
|
169
169
|
|
|
170
170
|
location = Path(location)
|
|
File without changes
|
|
File without changes
|