/usr/lib/python2.7/dist-packages/landslide/watcher.py is in python-landslide 1.1.3-0.0.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import sys
import time
try:
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler, DirModifiedEvent
except ImportError:
print('Error: The watchdog module must be installed to use the -w option')
print('Exiting...')
sys.exit(1)
def watch(watch_dir, generate_func):
event_handler = LandslideEventHandler(generate_func)
observer = Observer()
observer.schedule(event_handler, path=watch_dir, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
class LandslideEventHandler(FileSystemEventHandler):
def __init__(self, generate_func):
super(LandslideEventHandler, self).__init__()
self.generate_func = generate_func
def on_modified(self, event):
if isinstance(event, DirModifiedEvent):
self.generate_func()
|