forked from p15670423/monkey
Island: Remove unused environment_singleton
This commit is contained in:
parent
1231b6aa6c
commit
15a3e61ec0
|
@ -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
|
|
|
@ -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:
|
if str(MONKEY_ISLAND_DIR_BASE_PATH) not in sys.path:
|
||||||
sys.path.insert(0, MONKEY_ISLAND_DIR_BASE_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
|
import monkey_island.cc.setup.config_setup as config_setup # noqa: E402
|
||||||
from common.version import get_version # noqa: E402
|
from common.version import get_version # noqa: E402
|
||||||
from monkey_island.cc.app import init_app # 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):
|
def _initialize_globals(config_options: IslandConfigOptions, server_config_path: str):
|
||||||
env_singleton.initialize_from_file(server_config_path)
|
|
||||||
|
|
||||||
initialize_services(config_options.data_dir)
|
initialize_services(config_options.data_dir)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue