Remove superfluous warnings in HooksRunner
authorIustin Pop <iustin@google.com>
Wed, 3 Mar 2010 12:50:52 +0000 (13:50 +0100)
committerIustin Pop <iustin@google.com>
Mon, 8 Mar 2010 13:48:25 +0000 (14:48 +0100)
For non-existing hooks (the majority of cases probably), logging a
warning every time is not helpful. So we first check if we have a valid
directory.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/backend.py

index 4732d56..fa95525 100644 (file)
@@ -2679,9 +2679,16 @@ class HooksRunner(object):
 
     subdir = "%s-%s.d" % (hpath, suffix)
     dir_name = "%s/%s" % (self._BASE_DIR, subdir)
-    runparts_results = utils.RunParts(dir_name, env=env, reset_env=True)
 
     results = []
+
+    if not os.path.isdir(dir_name):
+      # for non-existing/non-dirs, we simply exit instead of logging a
+      # warning at every operation
+      return results
+
+    runparts_results = utils.RunParts(dir_name, env=env, reset_env=True)
+
     for (relname, relstatus, runresult)  in runparts_results:
       if relstatus == constants.RUNPARTS_SKIP:
         rrval = constants.HKR_SKIP