Moved register event types to enumaration

This commit is contained in:
İsmail Başaran 2016-03-30 10:51:32 +03:00
parent f82e7c4f02
commit 721096b114
2 changed files with 11 additions and 6 deletions

View file

@ -12,6 +12,7 @@ import subprocess
from base.Scope import Scope from base.Scope import Scope
from base.model.Policy import Policy from base.model.Policy import Policy
from base.model.Task import Task from base.model.Task import Task
from base.model.MessageType import MessageType
class ExecutionManager(object): class ExecutionManager(object):
@ -28,12 +29,11 @@ class ExecutionManager(object):
self.logger = scope.getLogger() self.logger = scope.getLogger()
self.db_service = scope.getDbService() self.db_service = scope.getDbService()
# TODO move this event names to enumeration self.event_manager.register_event(MessageType.EXECUTE_SCRIPT, self.execute_script)
self.event_manager.register_event('EXECUTE_SCRIPT', self.execute_script) self.event_manager.register_event(MessageType.REQUEST_FILE, self.request_file)
self.event_manager.register_event('REQUEST_FILE', self.request_file) self.event_manager.register_event(MessageType.MOVE_FILE, self.move_file)
self.event_manager.register_event('MOVE_FILE', self.move_file) self.event_manager.register_event(MessageType.EXECUTE_TASK, self.execute_task)
self.event_manager.register_event('EXECUTE_TASK', self.execute_task) self.event_manager.register_event(MessageType.EXECUTE_POLICY, self.execute_policy)
self.event_manager.register_event('EXECUTE_POLICY', self.execute_policy)
def execute_policy(self, arg): def execute_policy(self, arg):

View file

@ -12,3 +12,8 @@ class MessageType(Enum):
TASK_WARNING = 'TASK_WARNING' TASK_WARNING = 'TASK_WARNING'
POLICY_RECEIVED = 'POLICY_RECEIVED' POLICY_RECEIVED = 'POLICY_RECEIVED'
POLICY_PROCESSED = 'POLICY_PROCESSED' POLICY_PROCESSED = 'POLICY_PROCESSED'
EXECUTE_POLICY = 'EXECUTE_POLICY'
EXECUTE_TASK = 'EXECUTE_TASK'
MOVE_FILE = 'MOVE_FILE'
REQUEST_FILE = 'REQUEST_FILE'
EXECUTE_SCRIPT = 'EXECUTE_SCRIPT'