mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-26 00:02:19 +03:00
Merge branch 'master' of https://github.com/Pardus-Kurumsal/ahenk
This commit is contained in:
commit
9dfbbcf5fc
4 changed files with 42 additions and 0 deletions
13
opt/ahenk/base/model/safe_mode.py
Normal file
13
opt/ahenk/base/model/safe_mode.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: Volkan Şahin <volkansah.in> <bm.volkansahin@gmail.com>
|
||||
|
||||
|
||||
class SafeMode(object):
|
||||
|
||||
def __init__(self,username):
|
||||
self.username = username
|
||||
|
||||
@property
|
||||
def obj_name(self):
|
||||
return "SAFE_MODE"
|
|
@ -85,6 +85,11 @@ class Plugin(threading.Thread):
|
|||
elif obj_name == "KILL_SIGNAL":
|
||||
self.keep_run = False
|
||||
self.logger.debug('[Plugin] Killing queue ! Plugin Name : ' + str(self.name))
|
||||
elif obj_name == "SAFE_MODE":
|
||||
username = item_obj.username
|
||||
safe_mode_module = Scope.getInstance().getPluginManager().find_safe_mode_module(self.name)
|
||||
safe_mode_module.handle_safe_mode(username,self.context)
|
||||
self.context.empty_data()
|
||||
else:
|
||||
self.logger.warning("[Plugin] Not supported object type " + obj_name)
|
||||
except Exception as e:
|
||||
|
|
|
@ -9,6 +9,7 @@ from base.Scope import Scope
|
|||
from base.plugin.Plugin import Plugin
|
||||
from base.plugin.PluginQueue import PluginQueue
|
||||
from base.model.PluginKillSignal import PluginKillSignal
|
||||
from base.model.safe_mode import SafeMode
|
||||
|
||||
|
||||
class PluginManager(object):
|
||||
|
@ -131,6 +132,22 @@ class PluginManager(object):
|
|||
else:
|
||||
return True
|
||||
|
||||
def process_safe_mode(self,username):
|
||||
for plugin_name in self.pluginQueueDict:
|
||||
try:
|
||||
self.pluginQueueDict[plugin_name].put(SafeMode(username),1)
|
||||
except Exception as e:
|
||||
self.logger.error('Exception occured when switching safe mode ' + str(e))
|
||||
|
||||
def find_safe_mode_module(self,plugin_name):
|
||||
location = os.path.join(self.configManager.get("PLUGIN", "pluginFolderPath"), plugin_name)
|
||||
if os.path.isdir(location) and "safe.py" in os.listdir(location):
|
||||
info = imp.find_module("safe", [location])
|
||||
return imp.load_module("safe", *info)
|
||||
else:
|
||||
self.logger.warning('[PluginManager] safe.py not found Plugin Name : ' + str(plugin_name))
|
||||
return None
|
||||
|
||||
def reloadSinglePlugin(self, pluginName):
|
||||
# Not implemented yet
|
||||
|
||||
|
|
7
opt/ahenk/plugins/plugin1/safe.py
Normal file
7
opt/ahenk/plugins/plugin1/safe.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
|
||||
|
||||
def handle_safe_mode(username,context):
|
||||
pass
|
Loading…
Reference in a new issue