2016-02-29 10:48:00 +02:00
|
|
|
#!/usr/bin/python3
|
2016-02-18 16:38:30 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
2016-03-01 18:43:26 +02:00
|
|
|
import threading
|
|
|
|
from base.Scope import Scope
|
2016-02-18 16:38:30 +02:00
|
|
|
|
2016-03-01 18:43:26 +02:00
|
|
|
class Plugin(threading.Thread):
|
2016-02-18 16:38:30 +02:00
|
|
|
"""docstring for Plugin"""
|
2016-03-01 18:43:26 +02:00
|
|
|
def __init__(self, name,InQueue):
|
2016-02-18 16:38:30 +02:00
|
|
|
super(Plugin, self).__init__()
|
|
|
|
self.name = name
|
2016-03-01 18:43:26 +02:00
|
|
|
self.InQueue = InQueue
|
|
|
|
self.scope=Scope.getInstance()
|
|
|
|
self.pluginManager = self.scope.getPluginManager()
|
|
|
|
|
|
|
|
def run():
|
|
|
|
try:
|
|
|
|
task=self.InQueue.get()
|
2016-03-02 11:59:19 +02:00
|
|
|
command = self.pluginManager.findCommand(self.getName(),task.getCommandId())
|
2016-03-01 18:43:26 +02:00
|
|
|
command.handle_task(task)
|
|
|
|
# TODO add result to response queue
|
|
|
|
|
|
|
|
except Exception as e:
|
2016-03-02 11:59:19 +02:00
|
|
|
#TODO error log here
|
2016-03-01 18:43:26 +02:00
|
|
|
print("exception occured when executing plugin")
|
2016-02-18 16:38:30 +02:00
|
|
|
|
|
|
|
def getName(self):
|
|
|
|
return self.name
|