From c9a36a7085645a5d018ac59ceaaafd0171bcb420 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Wed, 25 Jul 2012 13:25:03 -0400 Subject: [PATCH] Adding an option to watch all extensions; useful for a VIM user where the filesystem events aren't triggered when saving a file without disabling backups. --- run_watch_data.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/run_watch_data.py b/run_watch_data.py index df7b3ccdec..eea721e4be 100755 --- a/run_watch_data.py +++ b/run_watch_data.py @@ -14,10 +14,11 @@ from watchdog.events import LoggingEventHandler, FileSystemEventHandler # To watch more (or more specific) directories, change WATCH_DIRS to include the # directories you want to watch. Note that this is recursive. If you want to -# watch fewer or more extensions, you can change EXTENSIONS. +# watch fewer or more extensions, you can change EXTENSIONS. To watch all +# extensions, add "*" to EXTENSIONS. WATCH_DIRS = ["../data"] -EXTENSIONS = ["xml", "js", "css", "coffee", "scss", "html"] +EXTENSIONS = ["*", "xml", "js", "css", "coffee", "scss", "html"] WATCH_DIRS = [os.path.abspath(os.path.normpath(dir)) for dir in WATCH_DIRS] @@ -30,12 +31,13 @@ class DjangoEventHandler(FileSystemEventHandler): def on_any_event(self, event): for extension in EXTENSIONS: - if event.src_path.endswith(extension): + if event.src_path.endswith(extension) or extension == "*": print "%s changed: restarting server." % event.src_path self.process.terminate() os.system("ps aux | grep 'django' | grep -v grep | awk '{print $2}' | xargs kill") time.sleep(0.25) self.process = Popen(['rake', 'lms']) + break if __name__ == "__main__": event_handler = DjangoEventHandler(Popen(['rake', 'lms']))