Skip to content

Commit

Permalink
TEMP: Moved init of bindings to the Controller's consructor
Browse files Browse the repository at this point in the history
  • Loading branch information
s-kostyuk committed Mar 8, 2018
1 parent fa1e8dd commit 922c3ec
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions dpl/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ def __init__(self):
self._connection_repo = ConnectionRepository()
self._thing_repo = ThingRepository()

is_safe_mode = self._core_config['is_safe_mode']

if is_safe_mode:
module_logger.warning(
"\n\n\nSafe mode is enabled, the most of everpl capabilities will be disabled\n\n")
module_logger.warning(
"\n!!! REST API access will be enabled in the safe mode !!!\n")

# Only REST API will be enabled in the safe mode
self._apis_config['enabled_apis'] = ('rest_api',)

# Force enable API access
self._core_config['is_api_enabled'] = True
else:
loop = asyncio.get_event_loop()
loop.run_until_complete(
self._bootstrap_integrations()
)

self._user_service_raw = UserService(self._user_repo)
self._session_service_raw = SessionService(self._session_repo)
self._auth_service = AuthService(self._user_service_raw, self._session_service_raw)
Expand Down Expand Up @@ -240,20 +259,6 @@ def apply_arguments(self, args) -> None:
self._apis_config['rest_api']['port'] = args.rest_api_port

async def start(self):
is_safe_mode = self._core_config['is_safe_mode']

if is_safe_mode:
module_logger.warning("\n\n\nSafe mode is enabled, the most of everpl capabilities will be disabled\n\n")
module_logger.warning("\n!!! REST API access will be enabled in the safe mode !!!\n")

# Only REST API will be enabled in the safe mode
self._apis_config['enabled_apis'] = ('rest_api', )

# Force enable API access
self._core_config['is_api_enabled'] = True
else:
await self._bootstrap_integrations()

# FIXME: Only for testing purposes
try:
self._user_service_raw.view_by_username('admin')
Expand Down

0 comments on commit 922c3ec

Please sign in to comment.