Updated stuff #297_cpl_update

This commit is contained in:
Sven Heidemann 2023-06-13 16:16:52 +02:00
parent 8ddb9f087a
commit f7ffd78dcc
5 changed files with 55 additions and 40 deletions

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==2023.4.0.post1", "cpl-core==2023.4.0.post2",
"cpl-translation==2023.4.0", "cpl-translation==2023.4.0.post1",
"cpl-query==2023.4.0", "cpl-query==2023.4.0.post1",
"cpl-discord==2023.4.0", "cpl-discord==2023.4.0.post2",
"Flask==2.3.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",
@ -32,7 +32,7 @@
"ariadne==0.19.1" "ariadne==0.19.1"
], ],
"DevDependencies": [ "DevDependencies": [
"cpl-cli==2023.4.0.post1", "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,43 @@
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() # st = FileLoggingSettings(s)
settings[s]["Key"] = s settings[s]["Key"] = s
st.from_dict(settings[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) # def from_dict(self, settings: dict):
Console.write_line(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings") # try:
Console.write_line(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}") # files = List(FileLoggingSettings)
Console.set_foreground_color(ForegroundColorEnum.default) # 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)

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()}")