#2447: cli commands for dev mode
This commit is contained in:
@@ -7,6 +7,8 @@ from primaite import _PRIMAITE_ROOT
|
||||
|
||||
__all__ = ["SIM_OUTPUT"]
|
||||
|
||||
from primaite.utils.cli.primaite_config_utils import get_primaite_config_dict, is_dev_mode
|
||||
|
||||
|
||||
class LogLevel(IntEnum):
|
||||
"""Enum containing all the available log levels for PrimAITE simulation output."""
|
||||
@@ -24,18 +26,29 @@ class LogLevel(IntEnum):
|
||||
|
||||
|
||||
class _SimOutput:
|
||||
_default_path = _PRIMAITE_ROOT.parent.parent / "simulation_output" / datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
|
||||
def __init__(self):
|
||||
self._path: Path = (
|
||||
_PRIMAITE_ROOT.parent.parent / "simulation_output" / datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
)
|
||||
self._path: Path = self._default_path
|
||||
self.save_pcap_logs: bool = False
|
||||
self.save_sys_logs: bool = False
|
||||
self.write_sys_log_to_terminal: bool = False
|
||||
self.sys_log_level: LogLevel = LogLevel.WARNING # default log level is at WARNING
|
||||
|
||||
if is_dev_mode():
|
||||
# if dev mode, override with the values configured via the primaite dev-mode command
|
||||
dev_config = get_primaite_config_dict().get("developer_mode")
|
||||
self.save_pcap_logs = dev_config["output_pcap_logs"]
|
||||
self.save_sys_logs = dev_config["output_sys_logs"]
|
||||
self.write_sys_log_to_terminal = dev_config["output_to_terminal"]
|
||||
|
||||
@property
|
||||
def path(self) -> Path:
|
||||
return self._path
|
||||
if not is_dev_mode():
|
||||
return self._path
|
||||
if is_dev_mode():
|
||||
dev_config = get_primaite_config_dict().get("developer_mode")
|
||||
return Path(dev_config["output_path"]) if dev_config["output_path"] else self._default_path
|
||||
|
||||
@path.setter
|
||||
def path(self, new_path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user