示例#1
0
 def handle(self, *args, **options):
     # First fill the cache
     files_source = force_utf8(settings.FILES_SOURCE)
     cache.cache_directory(files_source)
     for dirpath, dirnames, filenames in os.walk(files_source):
         for dirname in dirnames:
             cache.cache_directory(op.join(dirpath, dirname))
     # Then watch for changes
     manager = pyinotify.WatchManager()
     mask = (pyinotify.IN_DELETE | pyinotify.IN_CREATE |
             pyinotify.IN_MOVED_TO)
     manager.add_watch(files_source, mask, rec=True)
     notifier = pyinotify.Notifier(manager, self.update_dir)
     notifier.loop()
示例#2
0
 def handle(self, *args, **options):
     # First fill the cache
     logger.info("caching '%s'", settings.FILES_SOURCE)
     cache.cache_directory(settings.FILES_SOURCE)
     for dirpath, dirnames, filenames in os.walk(settings.FILES_SOURCE):
         for dirname in dirnames:
             cache.cache_directory(op.join(dirpath, dirname))
     # Then watch for changes
     manager = pyinotify.WatchManager()
     mask = (pyinotify.IN_DELETE | pyinotify.IN_CREATE |
             pyinotify.IN_MOVED_TO)
     manager.add_watch(settings.FILES_SOURCE, mask, rec=True)
     notifier = pyinotify.Notifier(manager, self.update_dir)
     logger.info("watching '%s' for changes", settings.FILES_SOURCE)
     notifier.loop()
示例#3
0
 def update_dir(self, event):
     path = force_utf8(event.pathname)
     cache.cache_directory(op.dirname(path))
示例#4
0
 def update_dir(self, event):
     logger.info("'%s' changed, updating its directory in cache", event.pathname)
     cache.cache_directory(op.dirname(event.pathname))