Ahenk/opt/ahenk/base/task/TaskManager.py

50 lines
1.6 KiB
Python
Raw Normal View History

2016-02-29 17:13:39 +02:00
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
from base.Scope import Scope
2016-03-14 10:55:28 +02:00
from base.model.MessageFactory import MessageFactory
from base.model.MessageType import MessageType
2016-02-29 17:13:39 +02:00
class TaskManager(object):
"""docstring for TaskManager"""
def __init__(self):
super(TaskManager, self).__init__()
scope = Scope.getInstance()
self.pluginManager = scope.getPluginManager()
self.logger= scope.getLogger()
2016-03-14 10:55:28 +02:00
self.dbService = scope.getDbService()
def addTask(self,task):
try:
2016-03-14 10:55:28 +02:00
self.logger.debug('Adding task ... ' + str(task.plugin_ame) + ' - ' + str(task.command_id))
self.saveTask(task)
# TODO send task received message
self.pluginManager.processTask(task)
except Exception as e:
# TODO error log here
2016-03-02 15:45:36 +02:00
pass
def saveTask(self,task):
# TODO not implemented yet
# task reveiced to ahenk save to db firstly.
# if user close before processing task you can load from db for process
pass
def updateTask(self,task):
# TODO not implemented yet
# This is updates task status processing - processed ...
pass
def deleteTask(self,task):
# TODO not implemented yet
# remove task if it is processed
pass
2016-03-14 10:55:28 +02:00
def sendMessage(self,type,message):
# TODO not implemented yet
pass
if __name__ == '__main__':
print(MessageFactory.createMessage(MessageType.TASK_PROCESSING,"my message"))