Removed application runtime | Code refactoring p.2
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import pathlib
|
||||
from datetime import datetime
|
||||
from socket import gethostname
|
||||
from typing import Optional
|
||||
|
||||
@@ -20,6 +22,11 @@ class ApplicationEnvironment(ApplicationEnvironmentABC):
|
||||
self._customer: Optional[str] = None
|
||||
self._content_root_path: Optional[str] = crp
|
||||
|
||||
self._start_time: datetime = datetime.now()
|
||||
self._end_time: datetime = datetime.now()
|
||||
self._working_directory = pathlib.Path().absolute()
|
||||
self._runtime_directory = pathlib.Path(__file__).parent.absolute()
|
||||
|
||||
@property
|
||||
def environment_name(self) -> str:
|
||||
return str(self._environment_name.value)
|
||||
@@ -55,3 +62,37 @@ class ApplicationEnvironment(ApplicationEnvironmentABC):
|
||||
@property
|
||||
def host_name(self):
|
||||
return gethostname()
|
||||
|
||||
@property
|
||||
def start_time(self) -> datetime:
|
||||
return self._start_time
|
||||
|
||||
@property
|
||||
def end_time(self) -> datetime:
|
||||
return self._end_time
|
||||
|
||||
@end_time.setter
|
||||
def end_time(self, end_time: datetime):
|
||||
self._end_time = end_time
|
||||
|
||||
@property
|
||||
def date_time_now(self) -> datetime:
|
||||
return datetime.now()
|
||||
|
||||
@property
|
||||
def working_directory(self) -> str:
|
||||
return self._working_directory
|
||||
|
||||
def set_working_directory(self, path: str = ''):
|
||||
if path != '':
|
||||
self._working_directory = path
|
||||
return
|
||||
|
||||
self._working_directory = pathlib.Path().absolute()
|
||||
|
||||
@property
|
||||
def runtime_directory(self) -> str:
|
||||
return self._runtime_directory
|
||||
|
||||
def set_runtime_directory(self, file: str):
|
||||
self._runtime_directory = pathlib.Path(file).parent.absolute()
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class ApplicationEnvironmentABC(ABC):
|
||||
@@ -45,3 +46,40 @@ class ApplicationEnvironmentABC(ABC):
|
||||
@property
|
||||
@abstractmethod
|
||||
def host_name(self) -> str: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def start_time(self) -> datetime: pass
|
||||
|
||||
@start_time.setter
|
||||
@abstractmethod
|
||||
def start_time(self, start_time: datetime): pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def end_time(self): pass
|
||||
|
||||
@end_time.setter
|
||||
@abstractmethod
|
||||
def end_time(self, end_time: datetime): pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def date_time_now(self) -> datetime: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def working_directory(self) -> str: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def runtime_directory(self) -> str: pass
|
||||
|
||||
@abstractmethod
|
||||
def set_runtime_directory(self, runtime_directory: str):
|
||||
"""
|
||||
Sets the current runtime directory
|
||||
:param runtime_directory:
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
Reference in New Issue
Block a user