Skip to content

Commit 066199b

Browse files
authored
Merge pull request DIRACGrid#8355 from DIRACGridBot/cherry-pick-2-7e87c8471-integration
[sweep:integration] fix: accounting for other formats (AREX CE)
2 parents f083725 + a05ef7f commit 066199b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/DIRAC/Resources/Computing/AREXComputingElement.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" AREX Computing Element (ARC REST interface)
1+
"""AREX Computing Element (ARC REST interface)
22
33
Allows interacting with ARC AREX services via a REST interface.
44
@@ -807,7 +807,23 @@ def getCEStatus(self):
807807
return S_ERROR(f"Failed decoding the status of the CE")
808808

809809
# Look only in the relevant section out of the headache
810-
queueInfo = ceData["Domains"]["AdminDomain"]["Services"]["ComputingService"]["ComputingShare"]
810+
# This "safe_get" function allows to go down the dictionary
811+
# even if some elements are lists instead of dictionaries
812+
# and returns None if any element is not found
813+
# FIXME: this is a temporary measure to be removed after https://github.com/DIRACGrid/DIRAC/issues/8354
814+
def safe_get(d, *keys):
815+
for k in keys:
816+
if isinstance(d, list):
817+
d = d[0] # assume first element
818+
d = d.get(k) if isinstance(d, dict) else None
819+
if d is None:
820+
break
821+
return d
822+
823+
queueInfo = safe_get(ceData, "Domains", "AdminDomain", "Services", "ComputingService", "ComputingShare")
824+
if queueInfo is None:
825+
self.log.error("Failed to extract queue info")
826+
811827
if not isinstance(queueInfo, list):
812828
queueInfo = [queueInfo]
813829

0 commit comments

Comments
 (0)