#127_config_in_wi #327

Merged
edraft merged 16 commits from #127_config_in_wi into 1.1.0 2023-08-14 19:08:22 +02:00
20 changed files with 126 additions and 342 deletions
Showing only changes of commit 2a435bc71c - Show all commits

View File

@ -16,24 +16,25 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core==2023.4.0.post2",
"cpl-core==2023.4.0.post5",
"cpl-translation==2023.4.0.post1",
"cpl-query==2023.4.0.post1",
"cpl-discord==2023.4.0.post3",
"Flask==2.3.2",
"Flask-Classful==0.14.2",
"Flask-Cors==3.0.10",
"PyJWT==2.7.0",
"Flask-Cors==4.0.0",
"PyJWT==2.8.0",
"waitress==2.1.2",
"Flask-SocketIO==5.3.4",
"eventlet==0.33.3",
"requests-oauthlib==1.3.1",
"icmplib==3.0.3",
"ariadne==0.19.1"
"ariadne==0.20.1",
"cryptography==41.0.2"
],
"DevDependencies": [
"cpl-cli==2023.4.0.post3",
"pygount==1.5.1"
"pygount==1.6.1"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

@ -1 +1 @@
Subproject commit 440fb3bd353dce31a2408c977a3168e3cfc32f9a
Subproject commit 42b9291f1a8484b3866a2e013b0f980aea093c4b

View File

@ -1,16 +1,13 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class ApiSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, port: int = None, host: str = None, redirect_uri: bool = None):
ConfigurationModelABC.__init__(self)
self._port = 80
self._host = ""
self._redirect_to_https = False
self._port = 80 if port is None else port
self._host = "" if host is None else host
self._redirect_to_https = False if redirect_uri is None else redirect_uri
@property
def port(self) -> int:
@ -23,12 +20,3 @@ class ApiSettings(ConfigurationModelABC):
@property
def redirect_to_https(self) -> bool:
return self._redirect_to_https
def from_dict(self, settings: dict):
try:
self._port = int(settings["Port"])
self._host = settings["Host"]
self._redirect_to_https = bool(settings["RedirectToHTTPS"])
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,19 +1,22 @@
import traceback
from datetime import datetime
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class AuthenticationSettings(ConfigurationModelABC):
def __init__(self):
def __init__(
self,
secret_key: str = None,
issuer: str = None,
audience: str = None,
token_expire_time: int = None,
refresh_token_expire_time: int = None,
):
ConfigurationModelABC.__init__(self)
self._secret_key = ""
self._issuer = ""
self._audience = ""
self._token_expire_time = 0
self._refresh_token_expire_time = 0
self._secret_key = "" if secret_key is None else secret_key
self._issuer = "" if issuer is None else issuer
self._audience = "" if audience is None else audience
self._token_expire_time = 0 if token_expire_time is None else token_expire_time
self._refresh_token_expire_time = 0 if refresh_token_expire_time is None else refresh_token_expire_time
@property
def secret_key(self) -> str:
@ -34,14 +37,3 @@ class AuthenticationSettings(ConfigurationModelABC):
@property
def refresh_token_expire_time(self) -> int:
return self._refresh_token_expire_time
def from_dict(self, settings: dict):
try:
self._secret_key = settings["SecretKey"]
self._issuer = settings["Issuer"]
self._audience = settings["Audience"]
self._token_expire_time = int(settings["TokenExpireTime"])
self._refresh_token_expire_time = int(settings["RefreshTokenExpireTime"])
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,19 +1,23 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
from cpl_query.extension import List
class DiscordAuthenticationSettings(ConfigurationModelABC):
def __init__(self):
def __init__(
self,
client_secret: str = None,
redirect_uri: str = None,
scope: list = None,
token_url: str = None,
auth_url: str = None,
):
ConfigurationModelABC.__init__(self)
self._client_secret = ""
self._redirect_url = ""
self._scope = List()
self._token_url = ""
self._auth_url = ""
self._client_secret = "" if client_secret is None else client_secret
self._redirect_url = "" if redirect_uri is None else redirect_uri
self._scope = List() if scope is None else List(str, scope)
self._token_url = "" if token_url is None else token_url
self._auth_url = "" if auth_url is None else auth_url
@property
def client_secret(self) -> str:
@ -34,14 +38,3 @@ class DiscordAuthenticationSettings(ConfigurationModelABC):
@property
def auth_url(self) -> str:
return self._auth_url
def from_dict(self, settings: dict):
try:
self._client_secret = settings["ClientSecret"]
self._redirect_url = settings["RedirectURL"]
self._scope = List(str, settings["Scope"])
self._token_url = settings["TokenURL"]
self._auth_url = settings["AuthURL"]
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,22 +1,12 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class FrontendSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, url: str = None):
ConfigurationModelABC.__init__(self)
self._url = ""
self._url = "" if url is None else url
@property
def url(self) -> str:
return self._url
def from_dict(self, settings: dict):
try:
self._url = settings["URL"]
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,49 +0,0 @@
from typing import Optional
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum
class VersionSettings(ConfigurationModelABC):
def __init__(self, major: str = None, minor: str = None, micro: str = None):
ConfigurationModelABC.__init__(self)
self._major: Optional[str] = major
self._minor: Optional[str] = minor
self._micro: Optional[str] = micro
@property
def major(self) -> str:
return self._major
@property
def minor(self) -> str:
return self._minor
@property
def micro(self) -> str:
return self._micro
def to_str(self) -> str:
if self._micro is None:
return f"{self._major}.{self._minor}"
else:
return f"{self._major}.{self._minor}.{self._micro}"
def from_dict(self, settings: dict):
self._major = settings[VersionSettingsNameEnum.major.value]
self._minor = settings[VersionSettingsNameEnum.minor.value]
micro = settings[VersionSettingsNameEnum.micro.value]
if micro != "":
self._micro = micro
def to_dict(self) -> dict:
version = {
VersionSettingsNameEnum.major.value: self._major,
VersionSettingsNameEnum.minor.value: self._minor,
}
if self._micro is not None:
version[VersionSettingsNameEnum.micro.value] = self._micro
return version

View File

@ -6,12 +6,12 @@ from bot_core.configuration.file_logging_settings import FileLoggingSettings
class BotLoggingSettings(ConfigurationModelABC):
def __init__(self, custom_logs: dict = None):
def __init__(self, **kwargs: dict):
ConfigurationModelABC.__init__(self)
self._files: List[FileLoggingSettings] = List(FileLoggingSettings)
if custom_logs is not None:
self._files_from_dict(custom_logs)
if kwargs is not None:
self._files_from_dict(kwargs)
@property
def files(self) -> List[FileLoggingSettings]:
@ -21,6 +21,5 @@ class BotLoggingSettings(ConfigurationModelABC):
files = List(FileLoggingSettings)
for s in settings:
settings[s]["Key"] = s
st = JSONProcessor.process(FileLoggingSettings, settings[s])
files.append(st)
files.append(JSONProcessor.process(FileLoggingSettings, settings[s]))
self._files = files

View File

@ -1,7 +1,7 @@
from cpl_core.configuration import ConfigurationModelABC
from cpl_core.utils.json_processor import JSONProcessor
from cpl_query.extension import List
from bot_api.json_processor import JSONProcessor
from bot_core.configuration.server_settings import ServerSettings
@ -12,7 +12,7 @@ class BotSettings(ConfigurationModelABC):
wait_for_restart: int = 2,
wait_for_shutdown: int = 2,
cache_max_messages: int = 1000,
server_settings: dict = None,
**kwargs: dict,
):
ConfigurationModelABC.__init__(self)
@ -23,8 +23,9 @@ class BotSettings(ConfigurationModelABC):
self._servers: List[ServerSettings] = List(ServerSettings)
if server_settings is not None:
self._servers_from_dict(server_settings)
for s in kwargs:
kwargs[s]["Id"] = s
self._servers.append(JSONProcessor.process(ServerSettings, kwargs[s]))
@property
def servers(self) -> List[ServerSettings]:
@ -53,27 +54,3 @@ class BotSettings(ConfigurationModelABC):
st = JSONProcessor.process(ServerSettings, settings[s])
servers.append(st)
self._servers = servers
# def from_dict(self, settings: dict):
# try:
# self._technicians = settings["Technicians"]
# self._wait_for_restart = settings["WaitForRestart"]
# self._wait_for_shutdown = settings["WaitForShutdown"]
# settings.pop("Technicians")
# settings.pop("WaitForRestart")
# settings.pop("WaitForShutdown")
#
# if "CacheMaxMessages" in settings:
# self._cache_max_messages = settings["CacheMaxMessages"]
# settings.pop("CacheMaxMessages")
#
# servers = List(ServerSettings)
# for s in settings:
# st = ServerSettings()
# settings[s]["Id"] = s
# st.from_dict(settings[s])
# servers.append(st)
# self._servers = servers
# except Exception as e:
# Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
# Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,13 +1,10 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
class FeatureFlagsSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, **kwargs: dict):
ConfigurationModelABC.__init__(self)
self._flags = {
@ -31,6 +28,12 @@ class FeatureFlagsSettings(ConfigurationModelABC):
FeatureFlagsEnum.config_in_wi.value: True, # 19.07.2023 #127
}
if len(kwargs.keys()) == 0:
return
for flag in [f.value for f in FeatureFlagsEnum]:
self._load_flag(kwargs, FeatureFlagsEnum(flag))
def get_flag(self, key: FeatureFlagsEnum) -> bool:
if key.value not in self._flags:
return False
@ -41,11 +44,3 @@ class FeatureFlagsSettings(ConfigurationModelABC):
return
self._flags[key.value] = bool(settings[key.value])
def from_dict(self, settings: dict):
try:
for flag in [f.value for f in FeatureFlagsEnum]:
self._load_flag(settings, FeatureFlagsEnum(flag))
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -17,11 +17,3 @@ class FileLoggingSettings(LoggingSettings):
@property
def key(self) -> str:
return self._key
# def from_dict(self, settings: dict):
# try:
# self._key = settings["Key"]
# super().from_dict(settings)
# except Exception as e:
# Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
# Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -10,9 +10,9 @@ class ServerSettings(ConfigurationModelABC):
):
ConfigurationModelABC.__init__(self)
self._id: int = id
self._message_delete_timer: int = message_delete_timer
self._notification_chat_id: int = notification_chat_id
self._id: int = 0 if id is None else id
self._message_delete_timer: int = 0 if message_delete_timer is None else message_delete_timer
self._notification_chat_id: int = 0 if notification_chat_id is None else notification_chat_id
@property
def id(self) -> int:
@ -25,12 +25,3 @@ class ServerSettings(ConfigurationModelABC):
@property
def notification_chat_id(self) -> int:
return self._notification_chat_id
# def from_dict(self, settings: dict):
# try:
# self._id = int(settings["Id"])
# self._message_delete_timer = int(settings["MessageDeleteTimer"])
# self._notification_chat_id = int(settings["NotificationChatId"])
# except Exception as e:
# Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in settings")
# Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,28 +1,41 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
from cpl_query.extension import List
class BaseServerSettings(ConfigurationModelABC):
def __init__(self):
def __init__(
self,
id: int = None,
max_voice_state_hours: int = None,
xp_per_message: int = None,
xp_per_reaction: int = None,
max_message_xp_per_hour: int = None,
xp_per_ontime_hour: int = None,
xp_per_event_participation: int = None,
xp_per_achievement: int = None,
afk_channel_ids: List = None,
afk_command_channel_id: int = None,
help_command_reference_url: str = None,
help_voice_channel_id: int = None,
team_channel_id: int = None,
ping_urls: list = None,
):
ConfigurationModelABC.__init__(self)
self._id: int = 0
self._max_voice_state_hours: int = 0
self._xp_per_message: int = 0
self._xp_per_reaction: int = 0
self._max_message_xp_per_hour: int = 0
self._xp_per_ontime_hour: int = 0
self._xp_per_event_participation: int = 0
self._xp_per_achievement: int = 0
self._afk_channel_ids: List[int] = List(int)
self._afk_command_channel_id: int = 0
self._help_command_reference_url: str = ""
self._help_voice_channel_id: int = 0
self._team_channel_id: int = 0
self._ping_urls = List(str)
self._id = 0 if id is None else id
self._max_voice_state_hours = 0 if max_voice_state_hours is None else max_voice_state_hours
self._xp_per_message = 0 if xp_per_message is None else xp_per_message
self._xp_per_reaction = 0 if xp_per_reaction is None else xp_per_reaction
self._max_message_xp_per_hour = 0 if max_message_xp_per_hour is None else max_message_xp_per_hour
self._xp_per_ontime_hour = 0 if xp_per_ontime_hour is None else xp_per_ontime_hour
self._xp_per_event_participation = 0 if xp_per_event_participation is None else xp_per_event_participation
self._xp_per_achievement = 0 if xp_per_achievement is None else xp_per_achievement
self._afk_channel_ids = List(int) if afk_channel_ids is None else List(int, afk_channel_ids)
self._afk_command_channel_id = 0 if afk_command_channel_id is None else afk_command_channel_id
self._help_command_reference_url = "" if help_command_reference_url is None else help_command_reference_url
self._help_voice_channel_id = 0 if help_voice_channel_id is None else help_voice_channel_id
self._team_channel_id = 0 if team_channel_id is None else team_channel_id
self._ping_urls = List(str) if ping_urls is None else List(str, ping_urls)
@property
def id(self) -> int:
@ -79,26 +92,3 @@ class BaseServerSettings(ConfigurationModelABC):
@property
def ping_urls(self) -> List[str]:
return self._ping_urls
def from_dict(self, settings: dict):
try:
self._id = int(settings["Id"])
self._max_voice_state_hours = int(settings["MaxVoiceStateHours"])
self._xp_per_message = int(settings["XpPerMessage"])
self._xp_per_reaction = int(settings["XpPerReaction"])
self._max_message_xp_per_hour = int(settings["MaxMessageXpPerHour"])
self._xp_per_ontime_hour = int(settings["XpPerOntimeHour"])
self._xp_per_event_participation = (
0 if "XpPerEventParticipation" not in settings else settings["XpPerEventParticipation"]
)
for index in settings["AFKChannelIds"]:
self._afk_channel_ids.append(int(index))
self._afk_command_channel_id = settings["AFKCommandChannelId"]
self._help_command_reference_url = settings["HelpCommandReferenceUrl"]
self._help_voice_channel_id = settings["HelpVoiceChannelId"]
self._team_channel_id = settings["TeamChannelId"]
for url in settings["PingURLs"]:
self._ping_urls.append(url)
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,31 +1,19 @@
import traceback
from cpl_core.configuration import ConfigurationModelABC
from cpl_core.console import Console
from cpl_core.utils.json_processor import JSONProcessor
from cpl_query.extension import List
from modules.base.configuration.base_server_settings import BaseServerSettings
class BaseSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, **kwargs: dict):
ConfigurationModelABC.__init__(self)
self._servers: List[BaseServerSettings] = List()
for s in kwargs:
kwargs[s]["Id"] = s
self._servers.append(JSONProcessor.process(BaseServerSettings, kwargs[s]))
@property
def servers(self) -> List[BaseServerSettings]:
return self._servers
def from_dict(self, settings: dict):
try:
servers = List(BaseServerSettings)
for s in settings:
st = BaseServerSettings()
settings[s]["Id"] = s
st.from_dict(settings[s])
servers.append(st)
self._servers = servers
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -8,7 +8,6 @@ from cpl_translation import TranslatePipe
from discord import guild
from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.configuration.server_settings import ServerSettings
from modules.boot_log.configuration.boot_log_server_settings import (
BootLogServerSettings,
)
@ -58,11 +57,6 @@ class BootLogOnReadyEvent(OnReadyABC):
g: guild = g
self._logger.debug(__name__, f"Server detected: {g.id}")
server_settings: ServerSettings = self._config.get_configuration(f"ServerSettings_{g.id}")
if server_settings is None:
self._logger.error(__name__, f"BootLog settings for server {g.id} not found!")
return
module_settings: BootLogServerSettings = self._config.get_configuration(f"BootLogServerSettings_{g.id}")
if module_settings is None:
self._logger.error(__name__, f"Config {type(self).__name__}_{g.id} not found!")

View File

@ -1,15 +1,12 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class BootLogServerSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, id: int = None, login_message_channel_id: int = None):
ConfigurationModelABC.__init__(self)
self._id: int = 0
self._login_message_channel_id: int = 0
self._id: int = 0 if id is None else id
self._login_message_channel_id: int = 0 if login_message_channel_id is None else login_message_channel_id
@property
def id(self) -> int:
@ -18,11 +15,3 @@ class BootLogServerSettings(ConfigurationModelABC):
@property
def login_message_channel_id(self) -> int:
return self._login_message_channel_id
def from_dict(self, settings: dict):
try:
self._id = int(settings["Id"])
self._login_message_channel_id = int(settings["LoginMessageChannelId"])
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,7 +1,5 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
from cpl_core.utils.json_processor import JSONProcessor
from cpl_query.extension import List
from modules.boot_log.configuration.boot_log_server_settings import (
@ -10,24 +8,14 @@ from modules.boot_log.configuration.boot_log_server_settings import (
class BootLogSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, **kwargs: dict):
ConfigurationModelABC.__init__(self)
self._servers: List[BootLogServerSettings] = List()
for s in kwargs:
kwargs[s]["Id"] = s
self._servers.append(JSONProcessor.process(BootLogServerSettings, kwargs[s]))
@property
def servers(self) -> List[BootLogServerSettings]:
return self._servers
def from_dict(self, settings: dict):
try:
servers = List(BootLogServerSettings)
for s in settings:
st = BootLogServerSettings()
settings[s]["Id"] = s
st.from_dict(settings[s])
servers.append(st)
self._servers = servers
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,18 +1,28 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
from cpl_query.extension import List
from bot_data.model.level import Level
class DefaultLevelSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, level_header: str = None, levels: list = None):
ConfigurationModelABC.__init__(self)
self._levels = List(Level)
self._level_header = ""
self._level_header = level_header
if levels is None:
return
for level in levels:
self._levels.append(
Level(
level["Name"],
level["Color"],
int(level["MinXp"]),
int(level["Permissions"]),
None,
)
)
@property
def levels(self) -> List[Level]:
@ -21,20 +31,3 @@ class DefaultLevelSettings(ConfigurationModelABC):
@property
def level_header(self) -> str:
return self._level_header
def from_dict(self, settings: dict):
try:
self._level_header = settings["LevelHeader"]
for level in settings["Levels"]:
self._levels.append(
Level(
level["Name"],
level["Color"],
int(level["MinXp"]),
int(level["Permissions"]),
None,
)
)
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,16 +1,13 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class PermissionServerSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, id: int = None, admin_role_ids: list = None, moderator_role_ids: list = None):
ConfigurationModelABC.__init__(self)
self._id: int = 0
self._admin_roles: list[int] = []
self._moderator_roles: list[int] = []
self._id: int = 0 if id is None else id
self._admin_roles: list[int] = [] if admin_role_ids is None else admin_role_ids
self._moderator_roles: list[int] = [] if moderator_role_ids is None else moderator_role_ids
@property
def id(self) -> int:
@ -23,15 +20,3 @@ class PermissionServerSettings(ConfigurationModelABC):
@property
def moderator_roles(self) -> list[int]:
return self._moderator_roles
def from_dict(self, settings: dict):
try:
self._id = int(settings["Id"])
for index in settings["AdminRoleIds"]:
self._admin_roles.append(int(index))
for index in settings["ModeratorRoleIds"]:
self._moderator_roles.append(int(index))
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -1,7 +1,5 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
from cpl_core.utils.json_processor import JSONProcessor
from cpl_query.extension import List
from modules.permission.configuration.permission_server_settings import (
@ -10,24 +8,14 @@ from modules.permission.configuration.permission_server_settings import (
class PermissionSettings(ConfigurationModelABC):
def __init__(self):
def __init__(self, **kwargs: dict):
ConfigurationModelABC.__init__(self)
self._servers: List[PermissionServerSettings] = List()
for s in kwargs:
kwargs[s]["Id"] = s
self._servers.append(JSONProcessor.process(PermissionServerSettings, kwargs[s]))
@property
def servers(self) -> List[PermissionServerSettings]:
return self._servers
def from_dict(self, settings: dict):
try:
servers = List(PermissionServerSettings)
for s in settings:
st = PermissionServerSettings()
settings[s]["Id"] = s
st.from_dict(settings[s])
servers.append(st)
self._servers = servers
except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")