mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 09:42:15 +03:00
plugin and task manager
This commit is contained in:
parent
55c430ed40
commit
8939ac4a36
4 changed files with 22 additions and 5 deletions
|
@ -14,6 +14,8 @@ class Scope(object):
|
|||
self.configurationManager=None
|
||||
self.messageManager=None
|
||||
self.logger=None
|
||||
self.pluginManager=None
|
||||
self.taskManager=None
|
||||
|
||||
@staticmethod
|
||||
def getInstance():
|
||||
|
@ -50,3 +52,15 @@ class Scope(object):
|
|||
|
||||
def setMessageManager(self,messageManager):
|
||||
self.messageManager = messageManager
|
||||
|
||||
def getPluginManager(self):
|
||||
return self.pluginManager
|
||||
|
||||
def setPluginManager(self,pluginManager):
|
||||
self.pluginManager = pluginManager
|
||||
|
||||
def getTaskManager(self):
|
||||
return self.TaskManager
|
||||
|
||||
def setTaskManager(self,taskManager):
|
||||
self.taskManager = taskManager
|
||||
|
|
|
@ -17,18 +17,19 @@ class PluginManager(object):
|
|||
self.pluginQueueDict = dict()
|
||||
self.logger = scope.getLogger()
|
||||
|
||||
def loadPlugins():
|
||||
def loadPlugins(self):
|
||||
self.plugins = []
|
||||
possibleplugins = os.listdir(self.configManager.get("PLUGIN", "pluginFolderPath"))
|
||||
for pname in possibleplugins:
|
||||
location = os.path.join(self.configManager.get("PLUGIN", "pluginFolderPath"), pname)
|
||||
if not os.path.isdir(location) or not self.configManager.get("PLUGIN", "mainModuleName") + ".py" in os.listdir(location):
|
||||
self.logger.debug('It is not a plugin location - %s - ',location)
|
||||
self.logger.debug('It is not a plugin location - - ')
|
||||
continue
|
||||
try:
|
||||
self.loadSinglePlugin(pname)
|
||||
except Exception as e:
|
||||
# TODO error log
|
||||
pass
|
||||
|
||||
def loadSinglePlugin(self,pluginName):
|
||||
# TODO check already loaded plugin
|
||||
|
@ -44,7 +45,7 @@ class PluginManager(object):
|
|||
info = imp.find_module(commandId, [location])
|
||||
return imp.load_module(commandId, *info)
|
||||
else:
|
||||
self.logger.warning('Command id - %s - not found',commandId)
|
||||
self.logger.warning('Command id - - not found')
|
||||
return None
|
||||
|
||||
def processTask(self,task):
|
||||
|
@ -54,6 +55,7 @@ class PluginManager(object):
|
|||
except Exception as e:
|
||||
# TODO error log here
|
||||
# TODO update task - status to not found command
|
||||
pass
|
||||
|
||||
def reloadPlugins(self):
|
||||
# Not implemented yet
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
|
||||
import Queue
|
||||
from queue import Queue
|
||||
|
||||
class PluginQueue(Queue.PriorityQueue):
|
||||
class PluginQueue(Queue):
|
||||
def __contains__(self, item):
|
||||
with self.mutex:
|
||||
return item in self.queue
|
||||
|
|
|
@ -19,6 +19,7 @@ class TaskManager(object):
|
|||
self.pluginManager.processTask(task)
|
||||
except Exception as e:
|
||||
# TODO error log here
|
||||
pass
|
||||
|
||||
def saveTask(self,task):
|
||||
# TODO not implemented yet
|
||||
|
|
Loading…
Reference in a new issue