+ def __init__(self, watch_manager):
+ """Initializes this class.
+
+ @type watch_manager: pyinotify.WatchManager
+ @param watch_manager: inotify watch manager
+
+ """
+ # pylint: disable=W0231
+ # no need to call the parent's constructor
+ self.watch_manager = watch_manager
+
+ def process_default(self, event):
+ logging.error("Received unhandled inotify event: %s", event)
+
+ def AddWatch(self, filename, mask):
+ """Adds a file watch.
+
+ @param filename: Path to file
+ @param mask: Inotify event mask
+ @return: Result
+
+ """
+ result = self.watch_manager.add_watch(filename, mask)
+
+ ret = result.get(filename, -1)
+ if ret <= 0:
+ raise errors.InotifyError("Could not add inotify watcher (%s)" % ret)