Ahenk/opt/ahenk/base/plugin/abstract_plugin.py

47 lines
1.5 KiB
Python
Raw Normal View History

2016-05-25 17:11:37 +03:00
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
# Author: Volkan Şahin <volkansah.in> <bm.volkansahin@gmail.com>
from base.Scope import Scope
2016-06-06 12:23:27 +03:00
from base.model.enum.ContentType import ContentType
2016-05-25 17:11:37 +03:00
from base.model.enum.MessageCode import MessageCode
2016-06-06 12:23:27 +03:00
from base.system.system import System
from base.util.util import Util
2016-05-25 17:11:37 +03:00
2016-06-06 12:23:27 +03:00
class AbstractPlugin(Util, System):
2016-05-25 17:11:37 +03:00
"""This is base class for plugins"""
def __init__(self):
2016-06-06 12:23:27 +03:00
super(AbstractPlugin, self).__init__()
2016-05-25 17:11:37 +03:00
self.scope = Scope.getInstance()
def handle_task(profile_data, context):
2016-05-26 11:20:33 +03:00
Scope.getInstance().getLogger().error('[AbstractPlugin] Handle function not found')
2016-05-25 17:11:37 +03:00
2016-05-26 11:20:33 +03:00
def get_message_code(self):
return MessageCode
2016-05-25 17:11:37 +03:00
2016-06-06 12:23:27 +03:00
def get_content_type(self):
return ContentType
2016-05-26 11:20:33 +03:00
def get_logger(self):
2016-05-25 17:11:37 +03:00
try:
2016-05-26 11:20:33 +03:00
return Scope.getInstance().getLogger()
2016-05-25 17:11:37 +03:00
except Exception as e:
2016-05-26 11:20:33 +03:00
self.scope.getLogger().error('[AbstractPlugin] A problem occurred while getting logger. Error Message: {}'.format(str(e)))
2016-05-25 17:11:37 +03:00
return None
2016-06-06 12:23:27 +03:00
2016-05-26 11:20:33 +03:00
def configuration_manager(self):
try:
return self.scope.getConfigurationManager()
except Exception as e:
self.logger().error('[AbstractPlugin] A problem occurred while getting configuration manager. Error Message: {}'.format(str(e)))
return None
2016-05-25 17:11:37 +03:00
2016-05-26 11:20:33 +03:00
def plugin_path(self):
return self.configuration_manager().get('PLUGIN', 'pluginfolderpath')