Vim editing bug fixed

parent 801271f2
reinstall:
pip uninstall nginx-redirector -y && python setup.py develop
......@@ -19,7 +19,7 @@ class RedirectorWatch:
self.logger = logger.Logger("redirector-watch.log")
self.redirector = Redirector()
self.parser = parser.ConfigReader(logger=self.logger)
self.mask = pyinotify.IN_MODIFY
self.mask = pyinotify.ALL_EVENTS
self.pool = {}
......@@ -50,6 +50,7 @@ class RedirectorWatch:
super().__init__(*args, **kwargs)
def process_IN_MODIFY(self, event):
print('event is', event)
try:
redirector_watch.pool[yaml_file][1].stop()
except RuntimeError as e:
......@@ -58,6 +59,17 @@ class RedirectorWatch:
print("Proccessing...")
self.redirector.generate(yaml_file, event.pathname)
redirector_watch.watch(yaml_file)
# fix bug with vim editing
def process_default(self, event):
if event.maskname == 'IN_MOVE_SELF':
redirector_watch.pool[yaml_file] = None
# correct path, deleting "-unknown-path" from path
corr_path = event.pathname.replace('-unknown-path', '')
print("Processing...")
self.redirector.generate(yaml_file, corr_path)
redirector_watch.watch(yaml_file)
return Watch
# we suggest that self.watch_manager already exists
......@@ -68,14 +80,15 @@ class RedirectorWatch:
notifier = pyinotify.ThreadedNotifier(wm, Watch_class(redirector=self.redirector))
notifier.start()
self.pool[yaml_file] = [wm, notifier]
print('self.pool is', self.pool)
#print('self.pool is', self.pool)
#print('notifier is', notifier)
def add_files(self, file_, wm):
file_list = self.parser.parse_yaml(file_)
for map_path, _ in file_list:
abs_map_path = os.path.abspath(map_path)
wdd = wm.add_watch(abs_map_path, self.mask, rec=True)
wdd = wm.add_watch(abs_map_path, self.mask, rec=True, auto_add=True)
class RedirectorWatchException(Exception):
def __init__(self, message, errors):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment