Skip to content

Commit 2e483a9

Browse files
author
Dennis Goeries
committed
MDL: Fix and reduce scope of runtime attrs in MDL
See merge request !2579
2 parents 916716d + 0d9dcdd commit 2e483a9

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/pythonKarabo/karabo/common/const.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@
119119
KARABO_RUNTIME_ATTRIBUTES_MDL = (
120120
KARABO_SCHEMA_MIN_EXC, KARABO_SCHEMA_MAX_EXC, KARABO_SCHEMA_MIN_INC,
121121
KARABO_SCHEMA_MAX_INC, KARABO_WARN_LOW, KARABO_WARN_HIGH,
122-
KARABO_ALARM_LOW, KARABO_ALARM_HIGH, KARABO_SCHEMA_METRIC_PREFIX_SYMBOL,
123-
KARABO_SCHEMA_UNIT_SYMBOL, KARABO_SCHEMA_DAQ_POLICY,
122+
KARABO_ALARM_LOW, KARABO_ALARM_HIGH, KARABO_SCHEMA_DAQ_POLICY,
124123
KARABO_SCHEMA_MIN_SIZE, KARABO_SCHEMA_MAX_SIZE,
125124
KARABO_SCHEMA_REQUIRED_ACCESS_LEVEL
126125
)

src/pythonKarabo/karabo/middlelayer_api/schema.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ def applyRuntimeUpdates(self, updates):
188188
:param updates: List of Hashes with "path", "attribute" and "value"
189189
:return success: True if all updates could be applied, False otherwise
190190
"""
191-
192191
def _applyAttribute(obj, path, attr_name, attr_value):
193192
# Basic check if the attribute is allowed to be set
194193
if attr_name not in KARABO_RUNTIME_ATTRIBUTES_MDL:
@@ -212,9 +211,14 @@ def _applyAttribute(obj, path, attr_name, attr_value):
212211
if not isinstance(attr, Attribute):
213212
# not Attribute type
214213
return False
215-
if attr.default and not isinstance(attr_value, type(attr.default)):
216-
# wrong attr value type
217-
return False
214+
215+
if attr.default:
216+
# convert the enum attribute value
217+
try:
218+
attr_value = type(attr.default)(attr_value)
219+
except ValueError:
220+
return False
221+
218222
# Apply attribute change
219223
setattr(desc, attr_name, attr_value)
220224
return True

0 commit comments

Comments
 (0)