mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-12-23 14:32:18 +03:00
task process fixed about according to TaskBean
This commit is contained in:
parent
773975bf17
commit
737c877894
3 changed files with 13 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue