A-0.1 - Modularer Aufbau #13

Merged
edraft merged 118 commits from 0.1 into Alpha 2021-11-25 21:02:12 +01:00
6 changed files with 44 additions and 19 deletions
Showing only changes of commit d413ace721 - Show all commits

View File

@ -7,10 +7,7 @@
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#06b9a5",
"activityBarBadge.foreground": "#15202b",
"editorGroup.border": "#fbed80",
"panel.border": "#fbed80",
"sash.hoverBorder": "#fbed80",
"sideBar.border": "#fbed80",
"statusBar.background": "#f9e64f",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#f7df1e",

View File

@ -4,10 +4,12 @@ from cpl_core.application import ApplicationBuilder, ApplicationABC
from gismo.application import Application
from gismo.startup import Startup
from modules.boot_log.boot_log_extension import BootLogExtension
async def main():
app_builder = ApplicationBuilder(Application)
app_builder.use_extension(BootLogExtension)
app_builder.use_startup(Startup)
app: ApplicationABC = await app_builder.build_async()
await app.run_async()

View File

@ -7,7 +7,7 @@ from cpl_core.environment import ApplicationEnvironment
from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.service.bot_service import BotService
from modules.boot_log.main import BootLog
from modules.boot_log.boot_log import BootLog
from modules_core.abc.module_abc import ModuleABC
from modules_core.abc.module_service_abc import ModuleServiceABC
from modules_core.service.module_service import ModuleService

View File

@ -0,0 +1,22 @@
from datetime import datetime
from cpl_core.configuration.configuration_abc import ConfigurationABC
from cpl_core.logging import LoggerABC
from gismo_core.abc.bot_service_abc import BotServiceABC
from modules_core.abc.module_abc import ModuleABC
from modules_core.abc.module_service_abc import ModuleServiceABC
class BootLog(ModuleABC):
def __init__(self, config: ConfigurationABC, logger: LoggerABC):
self._config = config
self._logger = logger
ModuleABC.__init__(self)
async def on_ready(self):
self._logger.info(__name__, f'Bot started')
start_time = self._config.get_configuration('StartTime')
init_time = round((datetime.now() - start_time).total_seconds(), 2)
self._logger.debug(__name__, f'InitTime: {init_time}s')

View File

@ -0,0 +1,19 @@
from datetime import datetime
from cpl_core.application.application_extension_abc import \
ApplicationExtensionABC
from cpl_core.configuration.configuration_abc import ConfigurationABC
from cpl_core.dependency_injection.service_provider_abc import \
ServiceProviderABC
from cpl_core.logging import LoggerABC
class BootLogExtension(ApplicationExtensionABC):
def __init__(self):
pass
async def run(self, config: ConfigurationABC, services: ServiceProviderABC):
logger: LoggerABC = services.get_service(LoggerABC)
logger.trace(__name__, 'Boot extension started')
config.add_configuration('StartTime', datetime.now())

View File

@ -1,15 +0,0 @@
from cpl_core.logging import LoggerABC
from gismo_core.abc.bot_service_abc import BotServiceABC
from modules_core.abc.module_abc import ModuleABC
from modules_core.abc.module_service_abc import ModuleServiceABC
class BootLog(ModuleABC):
def __init__(self, logger: LoggerABC):
self._logger = logger
ModuleABC.__init__(self)
async def on_ready(self):
self._logger.info(__name__, f'Bot started')