mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 02:42:16 +03:00
scheduler bug fixed
This commit is contained in:
parent
26c7a276cc
commit
facd78d9b5
2 changed files with 29 additions and 10 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
import json
|
||||
import threading
|
||||
|
||||
import ast
|
||||
from base.file.file_transfer_manager import FileTransferManager
|
||||
from base.model.enum.content_type import ContentType
|
||||
from base.model.enum.message_code import MessageCode
|
||||
|
@ -135,7 +135,8 @@ class Plugin(threading.Thread):
|
|||
self.logger.debug('[Plugin] Handling task')
|
||||
Scope.get_instance().get_plugin_manager().find_command(self.getName(),
|
||||
item_obj.get_plugin().get_version(),
|
||||
item_obj.get_command_cls_id().lower()).handle_task(task_data, self.context)
|
||||
item_obj.get_command_cls_id().lower()).handle_task(ast.literal_eval(str(task_data)), self.context)
|
||||
|
||||
|
||||
if self.context.data is not None and self.context.get('responseCode') is not None:
|
||||
self.logger.debug('[Plugin] Creating response')
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
|
||||
from base.model.task import Task
|
||||
from base.model.task_bean import TaskBean
|
||||
from base.model.plugin_bean import PluginBean
|
||||
from base.scope import Scope
|
||||
|
||||
|
||||
|
@ -38,14 +39,31 @@ class ScheduleTaskDB(object):
|
|||
try:
|
||||
self.logger.debug('Loading schedule tasks...')
|
||||
rows = self.db_service.select('schedule_task')
|
||||
tasks = []
|
||||
tasks = list()
|
||||
for row in rows:
|
||||
task_json = row['task_json']
|
||||
task = Task(None)
|
||||
task.from_json(task_json)
|
||||
tasks.append(task)
|
||||
tasks.append(self.get_task_by_id(row[1]))
|
||||
self.logger.debug(
|
||||
'Schedule tasks loaded successfully. Schedule Tasks size=' + str(len(tasks)))
|
||||
'Scheduled tasks are loaded successfully. Scheduled Tasks size is {0}'.format(str(len(tasks))))
|
||||
return tasks
|
||||
except Exception as e:
|
||||
self.logger.error('Exception occur when loading schedule tasks! ' + str(e))
|
||||
self.logger.error(
|
||||
'Exception occurred while loading schedule tasks. Error Message: {0}'.format(str(e)))
|
||||
|
||||
def get_task_by_id(self, task_id):
|
||||
self.logger.debug('Getting task from db.')
|
||||
try:
|
||||
db_task = self.db_service.select('task', criteria='id={0}'.format(task_id))[0]
|
||||
self.logger.debug('db_task-------->'+str(db_task))
|
||||
return TaskBean(db_task[0], db_task[1], db_task[2], db_task[3], db_task[4], db_task[5],
|
||||
self.get_plugin_by_id(db_task[6]), db_task[7], db_task[8])
|
||||
except Exception as e:
|
||||
self.logger.debug('A problem occurred while getting task by id. Error Message: {0}'.format(str(e)))
|
||||
|
||||
def get_plugin_by_id(self, plugin_id):
|
||||
self.logger.debug('Getting plugin from db.')
|
||||
db_plugin = self.db_service.select('plugin', criteria='id={0}'.format(plugin_id))[0]
|
||||
self.logger.debug('db_plugin-------->' + str(db_plugin))
|
||||
return PluginBean(db_plugin[0], db_plugin[1], db_plugin[2], db_plugin[3], db_plugin[4], db_plugin[5],
|
||||
db_plugin[6], db_plugin[7], db_plugin[8], db_plugin[11], db_plugin[9], db_plugin[10],
|
||||
db_plugin[12])
|
||||
|
||||
|
|
Loading…
Reference in a new issue