Merge pull request 'Updated packages #297_cpl_update' (#320) from #297_cpl_update into 1.1.0

Reviewed-on: sh-edraft.de/kd_discord_bot#320
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
This commit is contained in:
Sven Heidemann 2023-06-16 10:39:33 +02:00
commit c1ec7dd97b
6 changed files with 44 additions and 46 deletions

View File

@ -16,23 +16,23 @@
"LicenseName": "MIT", "LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.", "LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [ "Dependencies": [
"cpl-core==2022.12.1.post3", "cpl-core==2023.4.0.post2",
"cpl-translation==2022.12.1", "cpl-translation==2023.4.0.post1",
"cpl-query==2022.12.2.post2", "cpl-query==2023.4.0.post1",
"cpl-discord==2022.12.2.post1", "cpl-discord==2023.4.0.post3",
"Flask==2.2.2", "Flask==2.3.2",
"Flask-Classful==0.14.2", "Flask-Classful==0.14.2",
"Flask-Cors==3.0.10", "Flask-Cors==3.0.10",
"PyJWT==2.6.0", "PyJWT==2.7.0",
"waitress==2.1.2", "waitress==2.1.2",
"Flask-SocketIO==5.3.2", "Flask-SocketIO==5.3.4",
"eventlet==0.33.3", "eventlet==0.33.3",
"requests-oauthlib==1.3.1", "requests-oauthlib==1.3.1",
"icmplib==3.0.3", "icmplib==3.0.3",
"ariadne==0.17.1" "ariadne==0.19.1"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli==2022.12.1.post3", "cpl-cli==2023.4.0.post3",
"pygount==1.5.1" "pygount==1.5.1"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",

@ -1 +1 @@
Subproject commit 0c9463753731ab1f5d0f916d21ac7ea304742995 Subproject commit e1c1efac984a04826c0c2713a26129b9d34b21d6

View File

@ -1,5 +1,5 @@
from ariadne import graphql_sync 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.configuration import ConfigurationABC
from cpl_core.environment import ApplicationEnvironmentABC from cpl_core.environment import ApplicationEnvironmentABC
from flask import request, jsonify from flask import request, jsonify
@ -30,7 +30,7 @@ class GraphQLController:
if self._env.environment_name != "development": if self._env.environment_name != "development":
return "", 403 return "", 403
return PLAYGROUND_HTML, 200 return ExplorerGraphiQL().html(None), 200
@Route.post(f"{BasePath}") @Route.post(f"{BasePath}")
@Route.authorize(by_api_key=True) @Route.authorize(by_api_key=True)

View File

@ -1,32 +1,26 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC 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 cpl_query.extension import List
from bot_core.configuration.file_logging_settings import FileLoggingSettings from bot_core.configuration.file_logging_settings import FileLoggingSettings
class BotLoggingSettings(ConfigurationModelABC): class BotLoggingSettings(ConfigurationModelABC):
def __init__(self): def __init__(self, custom_logs: dict = None):
ConfigurationModelABC.__init__(self) ConfigurationModelABC.__init__(self)
self._files: List[FileLoggingSettings] = List(FileLoggingSettings) self._files: List[FileLoggingSettings] = List(FileLoggingSettings)
if custom_logs is not None:
self._files_from_dict(custom_logs)
@property @property
def files(self) -> List[FileLoggingSettings]: def files(self) -> List[FileLoggingSettings]:
return self._files return self._files
def from_dict(self, settings: dict): def _files_from_dict(self, settings: dict):
try:
files = List(FileLoggingSettings) files = List(FileLoggingSettings)
for s in settings: for s in settings:
st = FileLoggingSettings()
settings[s]["Key"] = s settings[s]["Key"] = s
st.from_dict(settings[s]) st = JSONProcessor.process(FileLoggingSettings, settings[s])
files.append(st) files.append(st)
self._files = files 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)

View File

@ -1,23 +1,27 @@
import traceback from cpl_core.logging import LoggingSettings, LoggingLevelEnum
from cpl_core.console import Console
from cpl_core.logging import LoggingSettings
class FileLoggingSettings(LoggingSettings): class FileLoggingSettings(LoggingSettings):
def __init__(self): def __init__(
LoggingSettings.__init__(self) 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 @property
def key(self) -> str: def key(self) -> str:
return self._key return self._key
def from_dict(self, settings: dict): # def from_dict(self, settings: dict):
try: # try:
self._key = settings["Key"] # self._key = settings["Key"]
super().from_dict(settings) # super().from_dict(settings)
except Exception as e: # except Exception as e:
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings") # Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}") # Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")

View File

@ -16,10 +16,10 @@
"LicenseName": "MIT", "LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.", "LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [ "Dependencies": [
"cpl-core>=1.0.7" "cpl-core==2022.12.0"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli>=1.0.7" "cpl-core==2022.12.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": {}, "PythonPath": {},