mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 11:12: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'])
|
||||
|
||||
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()
|
||||
else:
|
||||
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)
|
||||
|
||||
elif 'reload' == str(json_data['event']):
|
||||
plugin_name = str(json_data['plugins'])
|
||||
self.logger.info('[AhenkDeamon] {} plugin/s is/are reloading to ahenk'.format(plugin_name))
|
||||
|
||||
if plugin_name == 'all':
|
||||
self.logger.debug('[AhenkDeamon] All plugins are reloading to ahenk')
|
||||
plugin_manager.reload_plugins()
|
||||
else:
|
||||
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)
|
||||
|
||||
elif 'remove' == str(json_data['event']):
|
||||
plugin_name = str(json_data['plugins'])
|
||||
|
||||
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()
|
||||
else:
|
||||
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)
|
||||
|
||||
elif 'stop' == str(json_data['event']):
|
||||
|
|
|
@ -2,19 +2,18 @@ import os
|
|||
import signal
|
||||
import time
|
||||
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
from watchdog.observers import Observer
|
||||
# from watchdog.events import FileSystemEventHandler
|
||||
# from watchdog.observers import Observer
|
||||
|
||||
from base.command.commander import Commander
|
||||
from base.system.system import System
|
||||
|
||||
|
||||
"""
|
||||
class FileEventHandler(FileSystemEventHandler):
|
||||
def __init__(self, plugin_path):
|
||||
self.path = plugin_path
|
||||
|
||||
def process(self, event):
|
||||
|
||||
if event.event_type == 'created':
|
||||
result = Commander().set_event([None, 'load', '-p', event.src_path.replace(self.path, '')])
|
||||
if result is True:
|
||||
|
@ -32,9 +31,15 @@ class FileEventHandler(FileSystemEventHandler):
|
|||
if event.is_directory:
|
||||
self.process(event)
|
||||
|
||||
def on_modified(self,event):
|
||||
print("MODIFIED-"+str(event.src_path))
|
||||
|
||||
"""
|
||||
class PluginInstallListener:
|
||||
|
||||
def listen(self, path):
|
||||
pass
|
||||
"""
|
||||
observer = Observer()
|
||||
event_handler = FileEventHandler(path)
|
||||
observer.schedule(event_handler, path, recursive=False)
|
||||
|
@ -45,3 +50,4 @@ class PluginInstallListener:
|
|||
except KeyboardInterrupt:
|
||||
observer.stop()
|
||||
observer.join()
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue