forked from p15670423/monkey
Add `_expand_path()` to wrap `os.path.expandvars()\' and `os.path.expanduser()\'
This commit is contained in:
parent
5ba8effe1a
commit
227039f30c
|
@ -13,8 +13,8 @@ from monkey_island.cc.server_utils.consts import (
|
||||||
|
|
||||||
class IslandConfigOptions:
|
class IslandConfigOptions:
|
||||||
def __init__(self, config_contents: dict):
|
def __init__(self, config_contents: dict):
|
||||||
self.data_dir = os.path.expandvars(
|
self.data_dir = IslandConfigOptions._expand_path(
|
||||||
os.path.expanduser(config_contents.get("data_dir", DEFAULT_DATA_DIR))
|
config_contents.get("data_dir", DEFAULT_DATA_DIR)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log_level = config_contents.get("log_level", DEFAULT_LOG_LEVEL)
|
self.log_level = config_contents.get("log_level", DEFAULT_LOG_LEVEL)
|
||||||
|
@ -23,9 +23,13 @@ class IslandConfigOptions:
|
||||||
"mongodb", {"start_mongodb": DEFAULT_START_MONGO_DB}
|
"mongodb", {"start_mongodb": DEFAULT_START_MONGO_DB}
|
||||||
).get("start_mongodb", DEFAULT_START_MONGO_DB)
|
).get("start_mongodb", DEFAULT_START_MONGO_DB)
|
||||||
|
|
||||||
self.crt_path = os.path.expandvars(
|
self.crt_path = IslandConfigOptions._expand_path(
|
||||||
os.path.expanduser(config_contents.get("cert_path", DEFAULT_CRT_PATH))
|
config_contents.get("cert_path", DEFAULT_CRT_PATH)
|
||||||
)
|
)
|
||||||
self.key_path = os.path.expandvars(
|
self.key_path = IslandConfigOptions._expand_path(
|
||||||
os.path.expanduser(config_contents.get("key_path", DEFAULT_KEY_PATH))
|
config_contents.get("key_path", DEFAULT_KEY_PATH)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _expand_path(path: str) -> str:
|
||||||
|
return os.path.expandvars(os.path.expanduser(path))
|
||||||
|
|
Loading…
Reference in New Issue