added and use get_validated_detector_name_and_beamline

This commit is contained in:
NichtJens
2025-10-28 19:48:42 +01:00
parent 37f2c1d5e9
commit bc2a541667
3 changed files with 10 additions and 16 deletions
+1 -8
View File
@@ -141,14 +141,7 @@ class BrokerManager:
def power_on_detector(self, request, remote_ip):
validate.request_has(request, "detector_name")
beamline = get_beamline(remote_ip)
allowed_detectors_beamline = get_configured_detectors(beamline)
detector_name = request["detector_name"]
validate.detector_name_in_allowed_detectors_beamline(detector_name, allowed_detectors_beamline, beamline)
detector_name, beamline = validate.get_validated_detector_name_and_beamline(request, remote_ip)
request_power_on = {
"beamline": beamline,
+2 -7
View File
@@ -8,7 +8,6 @@ from sf_daq_broker.config import CONFIG_FILENAME_TIME_FORMAT
from sf_daq_broker.detector.jfctrl import JFCtrl
from sf_daq_broker.detector.detector import Detector
from sf_daq_broker.detector.trigger import Trigger
from sf_daq_broker.detector.utils import get_configured_detectors
from sf_daq_broker.utils import get_beamline, json_save, json_load, dueto, parse_det_name
from . import validate
@@ -109,13 +108,9 @@ class DetectorManager:
def set_detector_settings(self, request, remote_ip):
validate.request_has(request, "detector_name", "parameters")
validate.request_has(request, "parameters")
beamline = get_beamline(remote_ip)
allowed_detectors_beamline = get_configured_detectors(beamline)
detector_name = request["detector_name"]
validate.detector_name_in_allowed_detectors_beamline(detector_name, allowed_detectors_beamline, beamline)
detector_name, beamline = validate.get_validated_detector_name_and_beamline(request, remote_ip)
detector = Detector(detector_name)
+7 -1
View File
@@ -23,6 +23,11 @@ def detectors(ds):
def get_validated_detector_name(request, remote_ip):
detector_name, _beamline = get_validated_detector_name_and_beamline(request, remote_ip)
return detector_name
def get_validated_detector_name_and_beamline(request, remote_ip):
request_has(request, "detector_name")
beamline = get_beamline(remote_ip)
@@ -31,7 +36,8 @@ def get_validated_detector_name(request, remote_ip):
detector_name = request["detector_name"]
detector_name_in_allowed_detectors_beamline(detector_name, allowed_detectors_beamline, beamline)
return detector_name
return detector_name, beamline