From 15a3e61ec06e24a51fb63acf2b63a0c48f19f846 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 19 Nov 2021 08:36:11 -0500 Subject: [PATCH] Island: Remove unused environment_singleton --- .../cc/environment/environment_singleton.py | 34 ------------------- monkey/monkey_island/cc/server_setup.py | 3 -- 2 files changed, 37 deletions(-) delete mode 100644 monkey/monkey_island/cc/environment/environment_singleton.py diff --git a/monkey/monkey_island/cc/environment/environment_singleton.py b/monkey/monkey_island/cc/environment/environment_singleton.py deleted file mode 100644 index 4c5c6f744..000000000 --- a/monkey/monkey_island/cc/environment/environment_singleton.py +++ /dev/null @@ -1,34 +0,0 @@ -import logging - -from monkey_island.cc.environment import EnvironmentConfig, aws, password - -logger = logging.getLogger(__name__) - -AWS = "aws" -PASSWORD = "password" - -ENV_DICT = { - AWS: aws.AwsEnvironment, - PASSWORD: password.PasswordEnvironment, -} - -env = None - - -def set_env(env_type: str, env_config: EnvironmentConfig): - global env - if env_type in ENV_DICT: - env = ENV_DICT[env_type](env_config) - - -def initialize_from_file(file_path): - try: - config = EnvironmentConfig(file_path) - - __env_type = config.server_config - set_env(__env_type, config) - # noinspection PyUnresolvedReferences - logger.info("Monkey's env is: {0}".format(env.__class__.__name__)) - except Exception: - logger.error("Failed initializing environment", exc_info=True) - raise diff --git a/monkey/monkey_island/cc/server_setup.py b/monkey/monkey_island/cc/server_setup.py index 52a026fa7..65617774d 100644 --- a/monkey/monkey_island/cc/server_setup.py +++ b/monkey/monkey_island/cc/server_setup.py @@ -18,7 +18,6 @@ MONKEY_ISLAND_DIR_BASE_PATH = str(Path(__file__).parent.parent) if str(MONKEY_ISLAND_DIR_BASE_PATH) not in sys.path: sys.path.insert(0, MONKEY_ISLAND_DIR_BASE_PATH) -import monkey_island.cc.environment.environment_singleton as env_singleton # noqa: E402 import monkey_island.cc.setup.config_setup as config_setup # noqa: E402 from common.version import get_version # noqa: E402 from monkey_island.cc.app import init_app # noqa: E402 @@ -91,8 +90,6 @@ def _configure_logging(config_options): def _initialize_globals(config_options: IslandConfigOptions, server_config_path: str): - env_singleton.initialize_from_file(server_config_path) - initialize_services(config_options.data_dir)