Bugfixes for start service

This commit is contained in:
2022-05-24 20:12:59 +02:00
parent f317035342
commit a590cfd066
46 changed files with 116 additions and 94 deletions

View File

@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.validators'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.0rc1'
__version__ = '2022.6.1.dev2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='0.rc1')
version_info = VersionInfo(major='2022', minor='6', micro='1.dev2')

View File

@@ -1,17 +1,29 @@
import os
from cpl_cli import Error
from cpl_cli.configuration import WorkspaceSettings, ProjectSettings
from cpl_core.configuration import ConfigurationABC
from cpl_core.configuration.validator_abc import ValidatorABC
from cpl_core.environment import ApplicationEnvironmentABC
class ProjectValidator(ValidatorABC):
def __init__(self, workspace: WorkspaceSettings, project: ProjectSettings):
self._workspace = workspace
self._project = project
def __init__(self, config: ConfigurationABC, env: ApplicationEnvironmentABC, workspace: WorkspaceSettings, project: ProjectSettings):
self._config: ConfigurationABC = config
self._env: ApplicationEnvironmentABC = env
self._workspace: WorkspaceSettings = workspace
self._project: ProjectSettings = project
ValidatorABC.__init__(self)
def validate(self) -> bool:
if self._project is None and self._workspace is not None:
project = self._workspace.projects[self._workspace.default_project]
self._config.add_json_file(project, optional=True, output=False)
self._project = self._config.get_configuration(ProjectSettings)
self._env.set_working_directory(os.path.join(self._env.working_directory, os.path.dirname(project)))
result = self._project is not None or self._workspace is not None
if not result:
Error.error('The command requires to be run in an CPL project, but a project could not be found.')