adding new task to task list

This commit is contained in:
Volkan Şahin 2016-03-14 17:16:26 +02:00
parent 78b8d6d870
commit 4abb84a270
3 changed files with 13 additions and 8 deletions

View file

@ -5,6 +5,7 @@
import subprocess
from base.Scope import Scope
from base.messaging.MessageSender import MessageSender
from base.model.Task import Task
import hashlib,json,os,stat,shutil
class ExecutionManager(object):
@ -16,16 +17,19 @@ class ExecutionManager(object):
scope = Scope.getInstance()
self.config_manager = scope.getConfigurationManager()
self.event_manager = scope.getEventManager()
self.task_manager = scope.getTaskManager()
self.logger=scope.getLogger()
self.event_manager.register_event('EXECUTE_TASK',self.execute_task)
self.event_manager.register_event('EXECUTE_SCRIPT',self.execute_script)
self.event_manager.register_event('REQUEST_FILE',self.request_file)
self.event_manager.register_event('MOVE_FILE',self.move_file)
self.event_manager.register_event('TASK',self.add_task)
def execute_task(self,arg):
#TODO
def add_task(self,arg):
self.logger.debug('[ExecutionManager] Executing task...')
task = Task(arg)
self.task_manager.addTask(task)
def move_file(self,arg):
default_file_path=self.config_manager.get('CONNECTION', 'receiveFileParam')

View file

@ -7,20 +7,22 @@ class Task(object):
"""docstring for Task"""
def __init__(self,message):
self.payload = json.loads(message)
self.request = self.payload[u'request']
print(self.payload)
self.request = self.payload['request']
print(self.request)
@property
def getPluginName(self):
self.request[u'pluginName']
self.request['pluginName']
@property
def getCommandId(self):
self.request[u'commandId']
self.request['commandId']
@property
def params(self):
self.request[u'parameterMap']
self.request['parameterMap']
@property
def pluginVersion(self):
self.request[u'pluginVersion']
self.request['pluginVersion']

View file

@ -11,7 +11,6 @@ import json, uuid, netifaces, socket, datetime
class Registration():
#TODO keep catches and set logs
def __init__(self):
scope = Scope().getInstance()
self.conf_manager = scope.getConfigurationManager()