mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 10:11:33 +00:00
Change order of classes in directory_monitor.py
This commit is contained in:
parent
359e478069
commit
c8dca5f33b
@ -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'}})
|
||||
|
Loading…
Reference in New Issue
Block a user