forked from p34709852/monkey
29 lines
624 B
Python
29 lines
624 B
Python
import json
|
|
import logging
|
|
import standard
|
|
import aws
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
ENV_DICT = {
|
|
'standard': standard.StandardEnvironment,
|
|
'aws': aws.AwsEnvironment
|
|
}
|
|
|
|
|
|
def load_env_from_file():
|
|
with open('server_config.json', 'r') as f:
|
|
config_content = f.read()
|
|
config_json = json.loads(config_content)
|
|
return config_json['server_config']
|
|
|
|
|
|
try:
|
|
__env_type = load_env_from_file()
|
|
env = ENV_DICT[__env_type]()
|
|
logger.info('Monkey\'s env is: {0}'.format(env.__class__.__name__))
|
|
except Exception:
|
|
logger.error('Failed initializing environment', exc_info=True)
|
|
raise
|