From 4548253fedd9debfd01e4219c6628d5a409d6da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Tue, 26 Jul 2016 15:09:02 +0300 Subject: [PATCH] modified bug fixed and remove added --- .../base/plugin/plugin_install_listener.py | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/opt/ahenk/base/plugin/plugin_install_listener.py b/opt/ahenk/base/plugin/plugin_install_listener.py index 47cc387..48e9212 100644 --- a/opt/ahenk/base/plugin/plugin_install_listener.py +++ b/opt/ahenk/base/plugin/plugin_install_listener.py @@ -14,26 +14,24 @@ class FileEventHandler(FileSystemEventHandler): 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: - if System.Ahenk.is_running() is True: + + if event.src_path != self.path[:-1]: + if event.event_type in ('created', 'modified', 'moved'): + plu_path = event.src_path + if event.event_type == 'moved': + plu_path = event.dest_path + result = Commander().set_event([None, 'load', '-p', plu_path.replace(self.path, '')]) + if result is True and System.Ahenk.is_running() is True: + os.kill(int(System.Ahenk.get_pid_number()), signal.SIGALRM) + elif event.event_type == 'deleted': + result = Commander().set_event([None, 'remove', '-p', event.src_path.replace(self.path, '')]) + if result is True and System.Ahenk.is_running() is True: os.kill(int(System.Ahenk.get_pid_number()), signal.SIGALRM) - elif event.event_type == 'deleted': - # TODO - print('plugin removed') - def on_created(self, event): + def on_any_event(self, event): if event.is_directory: self.process(event) - def on_deleted(self, event): - if event.is_directory: - self.process(event) - - # def on_modified(self, event): - # print("MODIFIED-" + str(event.src_path)) - class PluginInstallListener: def listen(self, path):