From 8ddb9f087ac545828b09218005dc697728ec3943 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 12 Jun 2023 20:52:01 +0200 Subject: [PATCH 1/4] Updated packages #297_cpl_update --- kdb-bot/src/bot/bot.json | 18 +++++++++--------- kdb-bot/src/bot_graphql/bot-graphql.json | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index 507da098..dd99aa8d 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -16,23 +16,23 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core==2022.12.1.post3", - "cpl-translation==2022.12.1", - "cpl-query==2022.12.2.post2", - "cpl-discord==2022.12.2.post1", - "Flask==2.2.2", + "cpl-core==2023.4.0.post1", + "cpl-translation==2023.4.0", + "cpl-query==2023.4.0", + "cpl-discord==2023.4.0", + "Flask==2.3.2", "Flask-Classful==0.14.2", "Flask-Cors==3.0.10", - "PyJWT==2.6.0", + "PyJWT==2.7.0", "waitress==2.1.2", - "Flask-SocketIO==5.3.2", + "Flask-SocketIO==5.3.4", "eventlet==0.33.3", "requests-oauthlib==1.3.1", "icmplib==3.0.3", - "ariadne==0.17.1" + "ariadne==0.19.1" ], "DevDependencies": [ - "cpl-cli==2022.12.1.post3", + "cpl-cli==2023.4.0.post1", "pygount==1.5.1" ], "PythonVersion": ">=3.10.4", diff --git a/kdb-bot/src/bot_graphql/bot-graphql.json b/kdb-bot/src/bot_graphql/bot-graphql.json index bab3a067..5b48b407 100644 --- a/kdb-bot/src/bot_graphql/bot-graphql.json +++ b/kdb-bot/src/bot_graphql/bot-graphql.json @@ -16,10 +16,10 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=1.0.7" + "cpl-core==2022.12.0" ], "DevDependencies": [ - "cpl-cli>=1.0.7" + "cpl-core==2022.12.0" ], "PythonVersion": ">=3.10.4", "PythonPath": {}, From f7ffd78dcc3fb48388618f15c3f6bf49d5a113a7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 13 Jun 2023 16:16:52 +0200 Subject: [PATCH 2/4] Updated stuff #297_cpl_update --- kdb-bot/src/bot/bot.json | 10 ++-- kdb-bot/src/bot/config | 2 +- .../bot_api/controller/graphql_controller.py | 4 +- .../configuration/bot_logging_settings.py | 47 ++++++++++++------- .../configuration/file_logging_settings.py | 32 +++++++------ 5 files changed, 55 insertions(+), 40 deletions(-) diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index dd99aa8d..41e95b38 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -16,10 +16,10 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core==2023.4.0.post1", - "cpl-translation==2023.4.0", - "cpl-query==2023.4.0", - "cpl-discord==2023.4.0", + "cpl-core==2023.4.0.post2", + "cpl-translation==2023.4.0.post1", + "cpl-query==2023.4.0.post1", + "cpl-discord==2023.4.0.post2", "Flask==2.3.2", "Flask-Classful==0.14.2", "Flask-Cors==3.0.10", @@ -32,7 +32,7 @@ "ariadne==0.19.1" ], "DevDependencies": [ - "cpl-cli==2023.4.0.post1", + "cpl-cli==2023.4.0.post3", "pygount==1.5.1" ], "PythonVersion": ">=3.10.4", diff --git a/kdb-bot/src/bot/config b/kdb-bot/src/bot/config index 0c946375..e1c1efac 160000 --- a/kdb-bot/src/bot/config +++ b/kdb-bot/src/bot/config @@ -1 +1 @@ -Subproject commit 0c9463753731ab1f5d0f916d21ac7ea304742995 +Subproject commit e1c1efac984a04826c0c2713a26129b9d34b21d6 diff --git a/kdb-bot/src/bot_api/controller/graphql_controller.py b/kdb-bot/src/bot_api/controller/graphql_controller.py index d9072029..aefd8f13 100644 --- a/kdb-bot/src/bot_api/controller/graphql_controller.py +++ b/kdb-bot/src/bot_api/controller/graphql_controller.py @@ -1,5 +1,5 @@ from ariadne import graphql_sync -from ariadne.constants import PLAYGROUND_HTML +from ariadne.explorer import ExplorerGraphiQL from cpl_core.configuration import ConfigurationABC from cpl_core.environment import ApplicationEnvironmentABC from flask import request, jsonify @@ -30,7 +30,7 @@ class GraphQLController: if self._env.environment_name != "development": return "", 403 - return PLAYGROUND_HTML, 200 + return ExplorerGraphiQL().html(None), 200 @Route.post(f"{BasePath}") @Route.authorize(by_api_key=True) diff --git a/kdb-bot/src/bot_core/configuration/bot_logging_settings.py b/kdb-bot/src/bot_core/configuration/bot_logging_settings.py index b69e2c73..a91c5638 100644 --- a/kdb-bot/src/bot_core/configuration/bot_logging_settings.py +++ b/kdb-bot/src/bot_core/configuration/bot_logging_settings.py @@ -1,32 +1,43 @@ -import traceback - from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC -from cpl_core.console import Console, ForegroundColorEnum +from cpl_core.utils.json_processor import JSONProcessor from cpl_query.extension import List from bot_core.configuration.file_logging_settings import FileLoggingSettings class BotLoggingSettings(ConfigurationModelABC): - def __init__(self): + def __init__(self, custom_logs: dict = None): ConfigurationModelABC.__init__(self) self._files: List[FileLoggingSettings] = List(FileLoggingSettings) + if custom_logs is not None: + self._files_from_dict(custom_logs) + @property def files(self) -> List[FileLoggingSettings]: return self._files - def from_dict(self, settings: dict): - try: - files = List(FileLoggingSettings) - for s in settings: - st = FileLoggingSettings() - settings[s]["Key"] = s - st.from_dict(settings[s]) - files.append(st) - self._files = files - except Exception as e: - Console.set_foreground_color(ForegroundColorEnum.red) - Console.write_line(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings") - Console.write_line(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}") - Console.set_foreground_color(ForegroundColorEnum.default) + def _files_from_dict(self, settings: dict): + files = List(FileLoggingSettings) + for s in settings: + # st = FileLoggingSettings(s) + settings[s]["Key"] = s + # st.from_dict(settings[s]) + st = JSONProcessor.process(FileLoggingSettings, settings[s]) + files.append(st) + self._files = files + + # def from_dict(self, settings: dict): + # try: + # files = List(FileLoggingSettings) + # for s in settings: + # st = FileLoggingSettings() + # settings[s]["Key"] = s + # st.from_dict(settings[s]) + # files.append(st) + # self._files = files + # except Exception as e: + # Console.set_foreground_color(ForegroundColorEnum.red) + # Console.write_line(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings") + # Console.write_line(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}") + # Console.set_foreground_color(ForegroundColorEnum.default) diff --git a/kdb-bot/src/bot_core/configuration/file_logging_settings.py b/kdb-bot/src/bot_core/configuration/file_logging_settings.py index 58d461b9..b941601d 100644 --- a/kdb-bot/src/bot_core/configuration/file_logging_settings.py +++ b/kdb-bot/src/bot_core/configuration/file_logging_settings.py @@ -1,23 +1,27 @@ -import traceback - -from cpl_core.console import Console -from cpl_core.logging import LoggingSettings +from cpl_core.logging import LoggingSettings, LoggingLevelEnum class FileLoggingSettings(LoggingSettings): - def __init__(self): - LoggingSettings.__init__(self) + def __init__( + self, + key: str, + path: str = None, + filename: str = None, + console_log_level: LoggingLevelEnum = None, + file_log_level: LoggingLevelEnum = None, + ): + LoggingSettings.__init__(self, path, filename, console_log_level, file_log_level) - self._key = "" + self._key = key @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()}") + # 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()}") From fdf10f27284e584cb68e65da022e57803a12f020 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 13 Jun 2023 16:24:38 +0200 Subject: [PATCH 3/4] Updated cpl-discord #297_cpl_update --- kdb-bot/src/bot/bot.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index 41e95b38..54f2ec06 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -19,7 +19,7 @@ "cpl-core==2023.4.0.post2", "cpl-translation==2023.4.0.post1", "cpl-query==2023.4.0.post1", - "cpl-discord==2023.4.0.post2", + "cpl-discord==2023.4.0.post3", "Flask==2.3.2", "Flask-Classful==0.14.2", "Flask-Cors==3.0.10", From 979e0a0e6ffae38093e43a757de300b3155a898a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 14 Jun 2023 09:00:19 +0200 Subject: [PATCH 4/4] Removed comments #297_cpl_update --- .../configuration/bot_logging_settings.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/kdb-bot/src/bot_core/configuration/bot_logging_settings.py b/kdb-bot/src/bot_core/configuration/bot_logging_settings.py index a91c5638..1c0fb22a 100644 --- a/kdb-bot/src/bot_core/configuration/bot_logging_settings.py +++ b/kdb-bot/src/bot_core/configuration/bot_logging_settings.py @@ -20,24 +20,7 @@ class BotLoggingSettings(ConfigurationModelABC): def _files_from_dict(self, settings: dict): files = List(FileLoggingSettings) for s in settings: - # st = FileLoggingSettings(s) settings[s]["Key"] = s - # st.from_dict(settings[s]) st = JSONProcessor.process(FileLoggingSettings, settings[s]) files.append(st) self._files = files - - # def from_dict(self, settings: dict): - # try: - # files = List(FileLoggingSettings) - # for s in settings: - # st = FileLoggingSettings() - # settings[s]["Key"] = s - # st.from_dict(settings[s]) - # files.append(st) - # self._files = files - # except Exception as e: - # Console.set_foreground_color(ForegroundColorEnum.red) - # Console.write_line(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings") - # Console.write_line(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}") - # Console.set_foreground_color(ForegroundColorEnum.default)