1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-10-16 23:33:45 +03:00

More linting fixes

This commit is contained in:
Adolfo Gómez García
2023-04-15 05:33:01 +02:00
parent 54efa40eef
commit 025375e2fe
24 changed files with 248 additions and 235 deletions

View File

@@ -32,8 +32,6 @@
import logging
import typing
from django.db import transaction
from uds.core.util import singleton
from uds.models.notifications import Notification, NotificationLevel
@@ -42,19 +40,32 @@ if typing.TYPE_CHECKING:
logger = logging.getLogger(__name__)
class NotificationsManager(metaclass=singleton.Singleton):
"""
This class manages alerts and notifications
"""
def __init__(self):
pass
@staticmethod
def manager() -> 'NotificationsManager':
return NotificationsManager() # Singleton pattern will return always the same instance
return (
NotificationsManager()
) # Singleton pattern will return always the same instance
def notify(self, group: str, identificator: str, level: NotificationLevel, message: str, *args) -> None:
logger.debug('Notify: %s, %s, %s, %s, [%s]', group, identificator, level, message, args)
def notify(
self,
group: str,
identificator: str,
level: NotificationLevel,
message: str,
*args
) -> None:
logger.debug(
'Notify: %s, %s, %s, %s, [%s]', group, identificator, level, message, args
)
# Format the string
try:
message = message % args
@@ -63,7 +74,9 @@ class NotificationsManager(metaclass=singleton.Singleton):
# Store the notification on local persistent storage
# Will be processed by UDS backend
with Notification.atomicPersistent():
notify = Notification(group=group, identificator=identificator, level=level, message=message)
notify = Notification(
group=group, identificator=identificator, level=level, message=message
)
Notification.savePersistent(notify)
def registerGroup(self, group: str) -> None:
@@ -71,11 +84,9 @@ class NotificationsManager(metaclass=singleton.Singleton):
Registers a new group.
This is used to group notifications
"""
pass
def registerIdentificator(self, group: str, identificator: str) -> None:
"""
Registers a new identificator.
This is used to identify notifications
"""
pass