mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 09:42:15 +03:00
bug fixing about dynamic plugin load,reload and remove
This commit is contained in:
parent
f805748009
commit
c0598f608c
2 changed files with 16 additions and 9 deletions
|
@ -335,32 +335,33 @@ class AhenkDeamon(BaseDaemon):
|
||||||
plugin_name = str(json_data['plugins'])
|
plugin_name = str(json_data['plugins'])
|
||||||
|
|
||||||
if plugin_name == 'all':
|
if plugin_name == 'all':
|
||||||
self.logger.info('[AhenkDeamon] All plugins are loading to ahenk'.format(plugin_name))
|
self.logger.debug('[AhenkDeamon] All plugins are loading to ahenk')
|
||||||
plugin_manager.load_plugins()
|
plugin_manager.load_plugins()
|
||||||
else:
|
else:
|
||||||
for p_name in plugin_name.split(','):
|
for p_name in plugin_name.split(','):
|
||||||
self.logger.info('[AhenkDeamon] {} plugin is loading to ahenk'.format(p_name))
|
self.logger.debug('[AhenkDeamon] {} plugin is loading to ahenk'.format(p_name))
|
||||||
plugin_manager.load_single_plugin(p_name)
|
plugin_manager.load_single_plugin(p_name)
|
||||||
|
|
||||||
elif 'reload' == str(json_data['event']):
|
elif 'reload' == str(json_data['event']):
|
||||||
plugin_name = str(json_data['plugins'])
|
plugin_name = str(json_data['plugins'])
|
||||||
self.logger.info('[AhenkDeamon] {} plugin/s is/are reloading to ahenk'.format(plugin_name))
|
|
||||||
|
|
||||||
if plugin_name == 'all':
|
if plugin_name == 'all':
|
||||||
|
self.logger.debug('[AhenkDeamon] All plugins are reloading to ahenk')
|
||||||
plugin_manager.reload_plugins()
|
plugin_manager.reload_plugins()
|
||||||
else:
|
else:
|
||||||
for p_name in plugin_name.split(','):
|
for p_name in plugin_name.split(','):
|
||||||
|
self.logger.debug('[AhenkDeamon] {} plugin is reloading to ahenk'.format(p_name))
|
||||||
plugin_manager.reload_single_plugin(p_name)
|
plugin_manager.reload_single_plugin(p_name)
|
||||||
|
|
||||||
elif 'remove' == str(json_data['event']):
|
elif 'remove' == str(json_data['event']):
|
||||||
plugin_name = str(json_data['plugins'])
|
plugin_name = str(json_data['plugins'])
|
||||||
|
|
||||||
if plugin_name == 'all':
|
if plugin_name == 'all':
|
||||||
self.logger.info('[AhenkDeamon] All plugins are removing from ahenk'.format(plugin_name))
|
self.logger.debug('[AhenkDeamon] All plugins are removing from ahenk')
|
||||||
plugin_manager.remove_plugins()
|
plugin_manager.remove_plugins()
|
||||||
else:
|
else:
|
||||||
for p_name in plugin_name.split(','):
|
for p_name in plugin_name.split(','):
|
||||||
self.logger.info('[AhenkDeamon] {} plugin is removing from ahenk'.format(p_name))
|
self.logger.debug('[AhenkDeamon] {} plugin is removing from ahenk'.format(p_name))
|
||||||
plugin_manager.remove_single_plugin(p_name)
|
plugin_manager.remove_single_plugin(p_name)
|
||||||
|
|
||||||
elif 'stop' == str(json_data['event']):
|
elif 'stop' == str(json_data['event']):
|
||||||
|
|
|
@ -2,19 +2,18 @@ import os
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from watchdog.events import FileSystemEventHandler
|
# from watchdog.events import FileSystemEventHandler
|
||||||
from watchdog.observers import Observer
|
# from watchdog.observers import Observer
|
||||||
|
|
||||||
from base.command.commander import Commander
|
from base.command.commander import Commander
|
||||||
from base.system.system import System
|
from base.system.system import System
|
||||||
|
|
||||||
|
"""
|
||||||
class FileEventHandler(FileSystemEventHandler):
|
class FileEventHandler(FileSystemEventHandler):
|
||||||
def __init__(self, plugin_path):
|
def __init__(self, plugin_path):
|
||||||
self.path = plugin_path
|
self.path = plugin_path
|
||||||
|
|
||||||
def process(self, event):
|
def process(self, event):
|
||||||
|
|
||||||
if event.event_type == 'created':
|
if event.event_type == 'created':
|
||||||
result = Commander().set_event([None, 'load', '-p', event.src_path.replace(self.path, '')])
|
result = Commander().set_event([None, 'load', '-p', event.src_path.replace(self.path, '')])
|
||||||
if result is True:
|
if result is True:
|
||||||
|
@ -32,9 +31,15 @@ class FileEventHandler(FileSystemEventHandler):
|
||||||
if event.is_directory:
|
if event.is_directory:
|
||||||
self.process(event)
|
self.process(event)
|
||||||
|
|
||||||
|
def on_modified(self,event):
|
||||||
|
print("MODIFIED-"+str(event.src_path))
|
||||||
|
|
||||||
|
"""
|
||||||
class PluginInstallListener:
|
class PluginInstallListener:
|
||||||
|
|
||||||
def listen(self, path):
|
def listen(self, path):
|
||||||
|
pass
|
||||||
|
"""
|
||||||
observer = Observer()
|
observer = Observer()
|
||||||
event_handler = FileEventHandler(path)
|
event_handler = FileEventHandler(path)
|
||||||
observer.schedule(event_handler, path, recursive=False)
|
observer.schedule(event_handler, path, recursive=False)
|
||||||
|
@ -45,3 +50,4 @@ class PluginInstallListener:
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
observer.stop()
|
observer.stop()
|
||||||
observer.join()
|
observer.join()
|
||||||
|
"""
|
||||||
|
|
Loading…
Reference in a new issue