Added logic to load config from json & improved hosting and service providing

This commit is contained in:
2020-11-28 15:13:54 +01:00
parent ff577b121e
commit 44ffb4e574
29 changed files with 285 additions and 141 deletions

View File

@@ -0,0 +1,3 @@
# imports:
from .hosting_environment import HostingEnvironment

View File

@@ -0,0 +1,3 @@
# imports:
from .environment_base import EnvironmentBase

View File

@@ -0,0 +1,45 @@
from abc import ABC, abstractmethod
from sh_edraft.environment.model.environment_name import EnvironmentName
class EnvironmentBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def environment_name(self) -> EnvironmentName: pass
@environment_name.setter
@abstractmethod
def environment_name(self, environment_name: EnvironmentName): pass
@property
@abstractmethod
def application_name(self) -> str: pass
@application_name.setter
@abstractmethod
def application_name(self, application_name: str): pass
@property
@abstractmethod
def customer(self) -> str: pass
@customer.setter
@abstractmethod
def customer(self, customer: str): pass
@property
@abstractmethod
def content_root_path(self) -> str: pass
@content_root_path.setter
@abstractmethod
def content_root_path(self, content_root_path: str): pass
@property
@abstractmethod
def host_name(self) -> str: pass

View File

@@ -0,0 +1,52 @@
from socket import gethostname
from typing import Optional
from sh_edraft.environment.base.environment_base import EnvironmentBase
from sh_edraft.environment.model.environment_name import EnvironmentName
class HostingEnvironment(EnvironmentBase):
def __init__(self, name: EnvironmentName = EnvironmentName.production, crp: str = './'):
EnvironmentBase.__init__(self)
self._environment_name: Optional[EnvironmentName] = name
self._app_name: Optional[str] = None
self._customer: Optional[str] = None
self._content_root_path: Optional[str] = crp
@property
def environment_name(self) -> EnvironmentName:
return self._environment_name
@environment_name.setter
def environment_name(self, environment_name: EnvironmentName):
self._environment_name = environment_name
@property
def application_name(self) -> str:
return self._app_name if self._app_name is not None else ''
@application_name.setter
def application_name(self, application_name: str):
self._app_name = application_name
@property
def customer(self) -> str:
return self._customer if self._customer is not None else ''
@customer.setter
def customer(self, customer: str):
self._customer = customer
@property
def content_root_path(self) -> str:
return self._content_root_path
@content_root_path.setter
def content_root_path(self, content_root_path: str):
self._content_root_path = content_root_path
@property
def host_name(self):
return gethostname()

View File

@@ -0,0 +1,3 @@
# imports:
from .environment_name import EnvironmentName

View File

@@ -0,0 +1,9 @@
from enum import Enum
class EnvironmentName(Enum):
production = 'production'
staging = 'staging'
testing = 'testing'
development = 'development'