From 19e47583e9a5db88f208bdd8775f1cfce27f1b82 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 3 Jun 2021 15:51:36 -0400 Subject: [PATCH] island: Use `os.getcwd()` for MONKEY_ISLAND_ABS_PATH on Windows See issue #1207 for more details. --- monkey/monkey_island/cc/server_utils/consts.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/server_utils/consts.py b/monkey/monkey_island/cc/server_utils/consts.py index 6f4382b87..a14c69d0b 100644 --- a/monkey/monkey_island/cc/server_utils/consts.py +++ b/monkey/monkey_island/cc/server_utils/consts.py @@ -13,9 +13,17 @@ def get_default_data_dir() -> str: return r"$HOME/.monkey_island" +# TODO: Figure out why windows requires the use of `os.getcwd()`. See issue #1207. +def _get_monkey_island_abs_path() -> str: + if is_windows_os(): + return os.path.join(os.getcwd(), "monkey_island") + else: + return str(Path(__file__).resolve().parent.parent.parent) + + SERVER_CONFIG_FILENAME = "server_config.json" -MONKEY_ISLAND_ABS_PATH = str(Path(__file__).resolve().parent.parent.parent) +MONKEY_ISLAND_ABS_PATH = _get_monkey_island_abs_path() DEFAULT_DATA_DIR = os.path.expandvars(get_default_data_dir())