20260505 Backup

This commit is contained in:
2026-05-05 23:58:14 +00:00
parent a590cd030f
commit 0bc354d095
870 changed files with 30817 additions and 46676 deletions

View File

@@ -0,0 +1,43 @@
Logger = system.util.getLogger("alarm.summary")
def get_severity_style(level):
'''
level: Could be an int (1-4) or a string ("low", "Medium", etc)
'''
# 1. Maping names and values to normalize the input
name_to_level = {
'diagnostic':0, 'low':1, 'medium':2, 'high':3, 'critical':4
}
# 2. Convert a string to compare, if its a string or a number
normalized_level = level
if isinstance(level, basestring):
normalized_level = name_to_level.get(level.lower(), 0)
# 3. color definition
priorityBGColors = {1:"#7266B7", 2:"#F4B834", 3:"#DE7C33", 4:"#E22028"}
priorityTextColors = {1:"#FAFAFB", 2:"#FAFAFB", 3:"#FAFAFB", 4:"#FAFAFB"}
# 4. Return an object with the syle
if normalized_level not in priorityBGColors:
return {}
return {
"backgroundColor": priorityBGColors[normalized_level],
"color": priorityTextColors[normalized_level]
}
def getTop3Alarms():
res= []
activeAlarms = system.alarm.queryStatus(state=["ActiveUnacked"])
sortedAlarms = sorted(activeAlarms, key=lambda x: x.getPriority(), reverse=True)
for alm in sortedAlarms[:3]:
prio = str(alm.getPriority())
activeData = alm.getActiveData()
label = activeData.get(EventTime) # O alm.get('label')
res.append({
"value": {
"dispPath": alm.getDisplayPathOrSource(),
"label": alm.get("label")
},
"style": get_severity_style(prio)
})
return res