diff --git a/opt/ahenk/base/Scope.py b/opt/ahenk/base/Scope.py index 7125c80..41259f0 100644 --- a/opt/ahenk/base/Scope.py +++ b/opt/ahenk/base/Scope.py @@ -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 diff --git a/opt/ahenk/base/plugin/PluginManager.py b/opt/ahenk/base/plugin/PluginManager.py index caee36c..5e8180c 100644 --- a/opt/ahenk/base/plugin/PluginManager.py +++ b/opt/ahenk/base/plugin/PluginManager.py @@ -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 diff --git a/opt/ahenk/base/plugin/PluginQueue.py b/opt/ahenk/base/plugin/PluginQueue.py index df7a961..3d97edc 100644 --- a/opt/ahenk/base/plugin/PluginQueue.py +++ b/opt/ahenk/base/plugin/PluginQueue.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN -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 diff --git a/opt/ahenk/base/task/TaskManager.py b/opt/ahenk/base/task/TaskManager.py index 874ce07..82ab0bd 100644 --- a/opt/ahenk/base/task/TaskManager.py +++ b/opt/ahenk/base/task/TaskManager.py @@ -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