Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

edgify / rook   python

Repository URL to install this package:

/ com_ws / command_handler.py

import json
from rook.config import update_config

class CommandHandler(object):
    def __init__(self, agent_com, aug_manager):
        self._agent_com = agent_com
        self._aug_manager = aug_manager

        self._agent_com.on("InitialAugsCommand", self._handle_initial_augs)
        self._agent_com.on("AddAugCommand", self._handle_add_aug)
        self._agent_com.on("RemoveAugCommand", self._handle_remove_aug)

    def _handle_initial_augs(self, initial_augs):
        update_config(initial_augs.sdk_configuration)

        augs = [json.loads(aug_json) for aug_json in initial_augs.augs]
        self._aug_manager.initialize_augs(augs)

    def _handle_add_aug(self, command):
        self._aug_manager.add_aug(json.loads(command.aug_json))

    def _handle_remove_aug(self, command):
        self._aug_manager.remove_aug(command.aug_id)

    def __del__(self):
        pass