From c0598f608c1d2e42227c08e953f449f7f9e8d502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Tue, 19 Jul 2016 16:05:46 +0300 Subject: [PATCH] bug fixing about dynamic plugin load,reload and remove --- opt/ahenk/ahenkd.py | 11 ++++++----- opt/ahenk/base/plugin/plugin_install_listener.py | 14 ++++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/opt/ahenk/ahenkd.py b/opt/ahenk/ahenkd.py index b338104..a7b5e70 100755 --- a/opt/ahenk/ahenkd.py +++ b/opt/ahenk/ahenkd.py @@ -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']): diff --git a/opt/ahenk/base/plugin/plugin_install_listener.py b/opt/ahenk/base/plugin/plugin_install_listener.py index c31f51e..a1c1c5a 100644 --- a/opt/ahenk/base/plugin/plugin_install_listener.py +++ b/opt/ahenk/base/plugin/plugin_install_listener.py @@ -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() + """