Move `is_windows_os()` to separate file

This commit is contained in:
shreyamalviya 2021-05-20 16:35:19 +05:30 committed by Shreya
parent 2fb77fcb39
commit 37b7815e00
3 changed files with 10 additions and 7 deletions

View File

@ -1,10 +1,8 @@
import os
import sys
from monkey_island.cc.environment.utils import is_windows_os
from monkey_island.cc.environment.windows_permissions import set_full_folder_access
is_windows_os = sys.platform.startswith("win")
def create_data_dir(data_dir: str, create_parent_dirs: bool) -> None:
if not os.path.isdir(data_dir):
@ -12,5 +10,5 @@ def create_data_dir(data_dir: str, create_parent_dirs: bool) -> None:
os.makedirs(data_dir, mode=0o700)
else:
os.mkdir(data_dir, mode=0o700)
if is_windows_os: # `mode=0o700` doesn't work on Windows
if is_windows_os(): # `mode=0o700` doesn't work on Windows
set_full_folder_access(folder_path=data_dir)

View File

@ -0,0 +1,5 @@
import sys
def is_windows_os() -> bool:
return sys.platform.startswith("win")

View File

@ -1,12 +1,12 @@
import os
import sys
from monkey_island.cc.environment.utils import is_windows_os
__author__ = "itay.mizeretz"
def get_default_data_dir() -> str:
is_windows_os = sys.platform.startswith("win")
if is_windows_os:
if is_windows_os():
return r"%AppData%\monkey_island"
else:
return r"$HOME/.monkey_island"