mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-24 21:34:41 +03:00
advancing on notifications
This commit is contained in:
parent
801a4ef1a7
commit
d56ce0c653
@ -51,8 +51,8 @@ class MessageProcessorThread(BaseThread):
|
||||
|
||||
def run(self):
|
||||
# Load providers at beginning
|
||||
providers: typing.List[NotificationProviderModule] = [
|
||||
p.getInstance() for p in Notifier.objects.all()
|
||||
providers: typing.List[typing.Tuple[int, NotificationProviderModule]] = [
|
||||
(p.level, p.getInstance()) for p in Notifier.objects.all()
|
||||
]
|
||||
|
||||
while self.keepRunning:
|
||||
@ -83,10 +83,9 @@ class MessageProcessorThread(BaseThread):
|
||||
)
|
||||
|
||||
if notify:
|
||||
for p in providers:
|
||||
if (
|
||||
not self.keepRunning
|
||||
): # if we are asked to stop, we don't try to send anymore
|
||||
for p in (i[1] for i in providers if i[0] >= n.level):
|
||||
# if we are asked to stop, we don't try to send anymore
|
||||
if not self.keepRunning:
|
||||
break
|
||||
p.notify(n.group, n.identificator, n.level, n.message)
|
||||
|
||||
|
@ -78,8 +78,6 @@ class Notifier(Module):
|
||||
# : your own :py:meth:uds.core.module.BaseModule.icon method.
|
||||
iconFile: typing.ClassVar[str] = 'notifier.png'
|
||||
|
||||
level: NotificationLevel = NotificationLevel.ERROR
|
||||
|
||||
def __init__(self, environment: 'Environment', values: Module.ValuesType):
|
||||
super().__init__(environment, values)
|
||||
self.initialize(values)
|
||||
|
@ -53,7 +53,7 @@ class NotificationLevel(IntEnum):
|
||||
ERROR = 2
|
||||
CRITICAL = 3
|
||||
|
||||
# Return all notification levels as tuples of (level, name)
|
||||
# Return all notification levels as tuples of (level value, level name)
|
||||
@classmethod
|
||||
def all(cls):
|
||||
return [(level.value, level.name) for level in (cls.INFO, cls.WARNING, cls.ERROR, cls.CRITICAL)]
|
||||
|
Loading…
Reference in New Issue
Block a user