mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 09:42:15 +03:00
merging
This commit is contained in:
commit
885be4972d
7 changed files with 57 additions and 6 deletions
|
@ -11,6 +11,7 @@ This README would normally document whatever steps are necessary to get your app
|
|||
### How can I build and create deb file ? ###
|
||||
|
||||
Clone project and go to ahenk project folder, run command below
|
||||
|
||||
$ dpkg-buildpackage
|
||||
|
||||
### How do I get set up? ###
|
||||
|
|
|
@ -20,6 +20,7 @@ class Scope(object):
|
|||
self.registration=None
|
||||
self.eventManager=None
|
||||
self.executionManager=None
|
||||
self.dbService=None
|
||||
|
||||
|
||||
@staticmethod
|
||||
|
@ -93,3 +94,9 @@ class Scope(object):
|
|||
|
||||
def setExecutionManager(self,executionManager):
|
||||
self.executionManager=executionManager
|
||||
|
||||
def getDbService(self):
|
||||
return self.dbService
|
||||
|
||||
def setDbService(self,dbService):
|
||||
self.dbService = dbService
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
import sys
|
||||
sys.path.append('../..')
|
||||
import logging
|
||||
import logging.config
|
||||
from base.Scope import Scope
|
||||
|
|
16
opt/ahenk/base/model/MessageFactory.py
Normal file
16
opt/ahenk/base/model/MessageFactory.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
from base.model.MessageType import MessageType
|
||||
|
||||
class MessageFactory(object):
|
||||
|
||||
def createMessage(self,type,message):
|
||||
|
||||
if type == MessageType.TASK_RECEIVED:
|
||||
return "Message receivden response"
|
||||
elif type == MessageType.TASK_PROCESSING:
|
||||
return "Message processing response"
|
||||
else
|
||||
return None
|
||||
createMessage = staticmethod(createMessage)
|
13
opt/ahenk/base/model/MessageType.py
Normal file
13
opt/ahenk/base/model/MessageType.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
from enum import Enum
|
||||
|
||||
class MessageType(Enum):
|
||||
TASK_RECEIVED="TASK_RECEIVED"
|
||||
TASK_PROCESSING="TASK_PROCESSING"
|
||||
TASK_PROCESSED="TASK_PROCESSED"
|
||||
TASK_ERROR="TASK_ERROR"
|
||||
TASK_WARNING="TASK_WARNING"
|
||||
POLICY_RECEIVED="POLICY_RECEIVED"
|
||||
POLICY_PROCESSED="POLICY_PROCESSED"
|
|
@ -12,11 +12,15 @@ class Task(object):
|
|||
print(self.request)
|
||||
|
||||
@property
|
||||
def getPluginName(self):
|
||||
def task_id(self):
|
||||
self.request['id']
|
||||
|
||||
@property
|
||||
def plugin_name(self):
|
||||
self.request['pluginName']
|
||||
|
||||
@property
|
||||
def getCommandId(self):
|
||||
def command_id(self):
|
||||
self.request['commandId']
|
||||
|
||||
@property
|
||||
|
@ -24,5 +28,5 @@ class Task(object):
|
|||
self.request['parameterMap']
|
||||
|
||||
@property
|
||||
def pluginVersion(self):
|
||||
def plugin_version(self):
|
||||
self.request['pluginVersion']
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
from base.Scope import Scope
|
||||
from base.model.MessageFactory import MessageFactory
|
||||
from base.model.MessageType import MessageType
|
||||
|
||||
class TaskManager(object):
|
||||
"""docstring for TaskManager"""
|
||||
|
@ -10,11 +12,12 @@ class TaskManager(object):
|
|||
scope = Scope.getInstance()
|
||||
self.pluginManager = scope.getPluginManager()
|
||||
self.logger= scope.getLogger()
|
||||
self.dbService = scope.getDbService()
|
||||
|
||||
def addTask(self,task):
|
||||
try:
|
||||
# TODO add log
|
||||
# TODO save task to database
|
||||
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:
|
||||
|
@ -36,3 +39,11 @@ class TaskManager(object):
|
|||
# TODO not implemented yet
|
||||
# remove task if it is processed
|
||||
pass
|
||||
|
||||
def sendMessage(self,type,message):
|
||||
# TODO not implemented yet
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(MessageFactory.createMessage(MessageType.TASK_PROCESSING,"my message"))
|
||||
|
|
Loading…
Reference in a new issue