From 737c877894e0ee9a500c1cc792d1e1d7182b59ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Mon, 11 Apr 2016 19:32:05 +0300 Subject: [PATCH] task process fixed about according to TaskBean --- opt/ahenk/base/plugin/Plugin.py | 5 +++-- opt/ahenk/base/plugin/plugin_manager.py | 5 +++-- opt/ahenk/base/task/TaskManager.py | 13 +++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/opt/ahenk/base/plugin/Plugin.py b/opt/ahenk/base/plugin/Plugin.py index 588f3dc..59f22f8 100644 --- a/opt/ahenk/base/plugin/Plugin.py +++ b/opt/ahenk/base/plugin/Plugin.py @@ -35,6 +35,7 @@ class Plugin(threading.Thread): def __init__(self, name, InQueue): threading.Thread.__init__(self) + print('name:'+name) self.name = name self.InQueue = InQueue @@ -55,12 +56,12 @@ class Plugin(threading.Thread): obj_name = item_obj.obj_name print(obj_name) if obj_name == "TASK": - command = Scope.getInstance().getPluginManager().findCommand(self.getName(), item_obj.command_cls_id) + command = Scope.getInstance().getPluginManager().findCommand(self.getName(), item_obj.get_command_cls_id().lower()) command.handle_task(item_obj, self.context) # TODO create response message from context and item_obj. item_obj is task #TODO Message Code keep - response = Response(type=MessageType.TASK_STATUS, id=item_obj.id, code=MessageCode.TASK_PROCESSED, message='__message__', data=self.context.get('data'), content_type=self.context.get('content_type')) + response = Response(type=self.context.get('type'), id=self.context.get('taskId'), code=self.context.get('responseCode'), message=self.context.get('responseMessage'), data=self.context.get('responseData'), content_type=self.context.get('contentType')) #self.response_queue.put(self.messaging.response_msg(response)) #TODO DEBUG Scope.getInstance().getMessager().send_direct_message(self.messaging.response_msg(response)) #TODO REMOVE diff --git a/opt/ahenk/base/plugin/plugin_manager.py b/opt/ahenk/base/plugin/plugin_manager.py index 02a7181..7cf085a 100644 --- a/opt/ahenk/base/plugin/plugin_manager.py +++ b/opt/ahenk/base/plugin/plugin_manager.py @@ -62,9 +62,10 @@ class PluginManager(object): return None def processTask(self, task): + try: - if task.plugin.name.lower() in self.pluginQueueDict: - self.pluginQueueDict[task.plugin.name.lower()].put(task, 1) + if task.get_plugin().get_name().lower() in self.pluginQueueDict: + self.pluginQueueDict[task.get_plugin().get_name().lower()].put(task, 1) except Exception as e: # TODO update task - status to not found command self.logger.error("[PluginManager] Exception occurred when processing task " + str(e)) diff --git a/opt/ahenk/base/task/TaskManager.py b/opt/ahenk/base/task/TaskManager.py index fd3e103..a55e937 100644 --- a/opt/ahenk/base/task/TaskManager.py +++ b/opt/ahenk/base/task/TaskManager.py @@ -19,9 +19,9 @@ class TaskManager(object): def addTask(self, task): try: - if not task.cron_str == None or task.cron_str == '': + if task.get_cron_str() == None or task.get_cron_str() == '': self.logger.debug('Adding task ... ') - self.saveTask(task) + #self.saveTask(task) self.logger.info('Task saved ') # TODO send task received message self.pluginManager.processTask(task) @@ -42,10 +42,11 @@ class TaskManager(object): pass def saveTask(self, task): - cols = ['id', 'create_date', 'modify_date', 'command_cls_id', 'parameter_map', 'deleted', 'plugin'] - values = [str(task.id), str(task.create_date), str(task.modify_date), str(task.command_cls_id), str(task.parameter_map), str(task.deleted), task.plugin.to_string()] - self.db_service.update('task', cols, values, None) - self.logger.debug('[TaskManager] Task has been saved to database (Task id:' + task.id + ')') + pass + #cols = ['id', 'create_date', 'modify_date', 'command_cls_id', 'parameter_map', 'deleted', 'plugin'] + #values = [str(task.id), str(task.create_date), str(task.modify_date), str(task.command_cls_id), str(task.parameter_map), str(task.deleted), task.plugin.to_string()] + #self.db_service.update('task', cols, values, None) + #self.logger.debug('[TaskManager] Task has been saved to database (Task id:' + task.id + ')') def updateTask(self, task): # TODO not implemented yet