Change order of classes in directory_monitor.py

This commit is contained in:
Kristóf Tóth 2018-03-20 14:32:27 +01:00
parent 359e478069
commit c8dca5f33b

View File

@ -8,30 +8,6 @@ from tfw.config.logs import logging
log = logging.getLogger(__name__)
class WebideReloadEventHandler(FileSystemEventHandler):
def __init__(self):
super().__init__()
self.uplink = ServerUplinkConnector()
self._paused = False
self.ignore = 0
def pause(self):
self._paused = True
def resume(self):
self._paused = False
@RateLimiter(rate_per_second=2)
def on_modified(self, event):
if self._paused: return
if self.ignore > 0:
self.ignore = self.ignore - 1
return
log.debug(event)
key = 'webide'
self.uplink.send(key, {'data': {'command': 'reload'}})
class DirectoryMonitor:
def __init__(self, directory):
self.observer = Observer()
@ -65,3 +41,27 @@ class DirectoryMonitor:
self.directorymonitor.pause()
def __exit__(self, exc_type, exc_val, exc_tb):
self.directorymonitor.resume()
class WebideReloadEventHandler(FileSystemEventHandler):
def __init__(self):
super().__init__()
self.uplink = ServerUplinkConnector()
self._paused = False
self.ignore = 0
def pause(self):
self._paused = True
def resume(self):
self._paused = False
@RateLimiter(rate_per_second=2)
def on_modified(self, event):
if self._paused: return
if self.ignore > 0:
self.ignore = self.ignore - 1
return
log.debug(event)
key = 'webide'
self.uplink.send(key, {'data': {'command': 'reload'}})