I am trying to watch some text files for when they are modified using watchdog
but I only seem to get events for .tmp
files. I understand this is how sublime text is saving files, but shouldn't I also get an event fired for the actual file too?
This is what I get when trying to save a file at the location /home/john/resources/css/style.css
in sublime text:
/home/john/resources/css/.sublaa.tmp
/home/john/resources/css/.sublaa.tmp
/home/john/resources/css/.sublaa.tmp
It seems I only get events fired for the tmp files, but not for the actual file. This actually works fine on MacOSX, but not Ubuntu.
#!/usr/bin/python
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class MyHandler(FileSystemEventHandler):
def on_any_event(self, event):
print event.src_path
if __name__ == "__main__":
event_handler = MyHandler()
observer = Observer()
observer.schedule(event_handler, path='.', recursive=False)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()