minor fixing

This commit is contained in:
Volkan Şahin 2016-08-02 18:13:04 +03:00
parent 4d78384cb5
commit f3aa259944
3 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,33 @@
import os
import signal
from watchdog.events import FileSystemEventHandler
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.src_path != self.path[:-1]:
print('event_type:'+str(event.event_type))
if event.event_type in ('created', 'modified', 'moved'):
plu_path = event.src_path
if event.event_type == 'moved':
plu_path = event.dest_path
print('plu_path'+str(plu_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)
def on_any_event(self, event):
if event.is_directory:
self.process(event)

View file

@ -1,5 +1,3 @@
from multiprocessing import Process
class SetupTimer: class SetupTimer:
@staticmethod @staticmethod

View file

@ -1,6 +1,7 @@
import time import time
import threading import threading
class Timer(threading.Thread): class Timer(threading.Thread):
def __init__(self, timeout, timeout_function, checker_func=None, checker_success_function=None, **kwargs): def __init__(self, timeout, timeout_function, checker_func=None, checker_success_function=None, **kwargs):
threading.Thread.__init__(self) threading.Thread.__init__(self)