Added logic to load config from json & improved hosting and service providing
This commit is contained in:
3
src/sh_edraft/environment/__init__.py
Normal file
3
src/sh_edraft/environment/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# imports:
|
||||
|
||||
from .hosting_environment import HostingEnvironment
|
3
src/sh_edraft/environment/base/__init__.py
Normal file
3
src/sh_edraft/environment/base/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# imports:
|
||||
|
||||
from .environment_base import EnvironmentBase
|
45
src/sh_edraft/environment/base/environment_base.py
Normal file
45
src/sh_edraft/environment/base/environment_base.py
Normal 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
|
52
src/sh_edraft/environment/hosting_environment.py
Normal file
52
src/sh_edraft/environment/hosting_environment.py
Normal 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()
|
3
src/sh_edraft/environment/model/__init__.py
Normal file
3
src/sh_edraft/environment/model/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# imports:
|
||||
|
||||
from .environment_name import EnvironmentName
|
9
src/sh_edraft/environment/model/environment_name.py
Normal file
9
src/sh_edraft/environment/model/environment_name.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class EnvironmentName(Enum):
|
||||
|
||||
production = 'production'
|
||||
staging = 'staging'
|
||||
testing = 'testing'
|
||||
development = 'development'
|
Reference in New Issue
Block a user