kill signal was switched with shutdown mode and some log fixing

This commit is contained in:
Volkan Şahin 2016-07-22 10:34:59 +03:00
parent d63a455d39
commit 75b9f79ffd

View file

@ -4,11 +4,9 @@
# Author: Volkan Şahin <volkansah.in> <bm.volkansahin@gmail.com> # Author: Volkan Şahin <volkansah.in> <bm.volkansahin@gmail.com>
import imp import imp
import os import os
from multiprocessing import Process
from base.Scope import Scope from base.Scope import Scope
from base.model.PluginBean import PluginBean from base.model.PluginBean import PluginBean
from base.model.PluginKillSignal import PluginKillSignal
from base.model.modes.init_mode import InitMode from base.model.modes.init_mode import InitMode
from base.model.modes.login_mode import LoginMode from base.model.modes.login_mode import LoginMode
from base.model.modes.logout_mode import LogoutMode from base.model.modes.logout_mode import LogoutMode
@ -16,8 +14,6 @@ from base.model.modes.safe_mode import SafeMode
from base.model.modes.shutdown_mode import ShutdownMode from base.model.modes.shutdown_mode import ShutdownMode
from base.plugin.Plugin import Plugin from base.plugin.Plugin import Plugin
from base.plugin.PluginQueue import PluginQueue from base.plugin.PluginQueue import PluginQueue
from base.plugin.plugin_install_listener import PluginInstallListener
from base.system.system import System
# TODO create base abstract class # TODO create base abstract class
@ -31,6 +27,7 @@ class PluginManager(object):
self.db_service = self.scope.getDbService() self.db_service = self.scope.getDbService()
self.message_manager = self.scope.getMessageManager() self.message_manager = self.scope.getMessageManager()
self.logger = self.scope.getLogger() self.logger = self.scope.getLogger()
self.plugins = [] self.plugins = []
self.pluginQueueDict = dict() self.pluginQueueDict = dict()
@ -87,7 +84,7 @@ class PluginManager(object):
try: try:
self.logger.info('[PluginManager] Reloading plugins...') self.logger.info('[PluginManager] Reloading plugins...')
for p_queue in self.pluginQueueDict: for p_queue in self.pluginQueueDict:
self.pluginQueueDict[p_queue].put(PluginKillSignal()) self.pluginQueueDict[p_queue].put(ShutdownMode(), 1)
self.plugins = [] self.plugins = []
self.load_plugins() self.load_plugins()
self.logger.info('[PluginManager] Plugin reloaded successfully.') self.logger.info('[PluginManager] Plugin reloaded successfully.')
@ -108,8 +105,7 @@ class PluginManager(object):
try: try:
self.logger.debug('[PluginManager] Removing all plugins...') self.logger.debug('[PluginManager] Removing all plugins...')
for p_queue in self.pluginQueueDict: for p_queue in self.pluginQueueDict:
self.pluginQueueDict[p_queue].put(PluginKillSignal()) self.pluginQueueDict[p_queue].put(ShutdownMode(), 1)
# todo check is running
self.plugins = [] self.plugins = []
self.pluginQueueDict = dict() self.pluginQueueDict = dict()
self.logger.debug('[PluginManager] All plugins were removed successfully.') self.logger.debug('[PluginManager] All plugins were removed successfully.')
@ -121,7 +117,7 @@ class PluginManager(object):
self.logger.debug('[PluginManager] Trying to remove {} plugin...'.format(plugin_name)) self.logger.debug('[PluginManager] Trying to remove {} plugin...'.format(plugin_name))
if self.is_plugin_loaded(plugin_name): if self.is_plugin_loaded(plugin_name):
self.logger.debug('[PluginManager] {} plugin is killing...'.format(plugin_name)) self.logger.debug('[PluginManager] {} plugin is killing...'.format(plugin_name))
self.pluginQueueDict[plugin_name].put(PluginKillSignal(), 1) self.pluginQueueDict[plugin_name].put(ShutdownMode(), 1)
del self.pluginQueueDict[plugin_name] del self.pluginQueueDict[plugin_name]
for plugin in self.plugins: for plugin in self.plugins:
@ -184,10 +180,11 @@ class PluginManager(object):
if agent_profile.overridable.lower() != 'true': if agent_profile.overridable.lower() != 'true':
temp_list = [] temp_list = []
self.logger.debug('[PluginManager] User profile of {0} plugin will not executed because of profile override rules.'.format(agent_profile.plugin.name))
for usr_profile in user_profiles: for usr_profile in user_profiles:
if usr_profile.plugin.name != agent_profile.plugin.name: if usr_profile.plugin.name != agent_profile.plugin.name:
temp_list.append(usr_profile) temp_list.append(usr_profile)
else:
self.logger.debug('[PluginManager] User profile of {0} plugin will not executed because of profile override rules.'.format(agent_profile.plugin.name))
user_profiles = temp_list user_profiles = temp_list
else: else:
self.logger.debug('[PluginManager] Agent profile of {0} plugin will not executed because of profile override rules.'.format(agent_profile.plugin.name)) self.logger.debug('[PluginManager] Agent profile of {0} plugin will not executed because of profile override rules.'.format(agent_profile.plugin.name))
@ -265,7 +262,7 @@ class PluginManager(object):
info = imp.find_module(mode, [location]) info = imp.find_module(mode, [location])
return imp.load_module(mode, *info) return imp.load_module(mode, *info)
else: else:
self.logger.warning('[PluginManager] safe.py not found Plugin Name : ' + str(plugin_name)) self.logger.warning('[PluginManager] {0} not found in {1} plugin'.format((mode + '.py'), plugin_name))
return None return None
""" """