From 62fe861b93d08077ed2467855f95bf2c437f003b Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 20 Mar 2013 14:03:40 -0400 Subject: Inotify: produce better error when watching non-existent directory or file in such --- src/lib/Bcfg2/Server/FileMonitor/Inotify.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib/Bcfg2/Server/FileMonitor/Inotify.py') diff --git a/src/lib/Bcfg2/Server/FileMonitor/Inotify.py b/src/lib/Bcfg2/Server/FileMonitor/Inotify.py index 178a47b1a..b44ff6970 100644 --- a/src/lib/Bcfg2/Server/FileMonitor/Inotify.py +++ b/src/lib/Bcfg2/Server/FileMonitor/Inotify.py @@ -2,6 +2,7 @@ support. """ import os +import errno import logging import pyinotify from Bcfg2.Compat import reduce # pylint: disable=W0622 @@ -182,6 +183,9 @@ class Inotify(Pseudo, pyinotify.ProcessEvent): try: watchdir = self.watches_by_path[watch_path] except KeyError: + if not os.path.exists(watch_path): + raise OSError(errno.ENOENT, + "No such file or directory: '%s'" % path) watchdir = self.watchmgr.add_watch(watch_path, self.mask, quiet=False)[watch_path] self.watches_by_path[watch_path] = watchdir -- cgit v1.2.3-1-g7c22