If “utils.RunParts” were to raise an exception, a log message was
written and the code continued to run. Due to the exception the
“results” variable would not be defined.

Also change the code to log a backtrace (getting an exception is rather
unlikely and having a backtrace is useful) and update one comment.

Signed-off-by: Michael Hanselmann <[email protected]>
---
 lib/watcher/__init__.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/watcher/__init__.py b/lib/watcher/__init__.py
index c71bb88..ad023c2 100644
--- a/lib/watcher/__init__.py
+++ b/lib/watcher/__init__.py
@@ -71,7 +71,7 @@ KEY_RESTART_WHEN = "restart_when"
 KEY_BOOT_ID = "bootid"
 
 
-# Global client object
+# Global LUXI client object
 client = None
 
 
@@ -107,8 +107,9 @@ def RunWatcherHooks():
 
   try:
     results = utils.RunParts(hooks_dir)
-  except Exception, msg: # pylint: disable-msg=W0703
-    logging.critical("RunParts %s failed: %s", hooks_dir, msg)
+  except Exception: # pylint: disable-msg=W0703
+    logging.exception("RunParts %s failed: %s", hooks_dir)
+    return
 
   for (relname, status, runresult) in results:
     if status == constants.RUNPARTS_SKIP:
-- 
1.7.3.5

Reply via email to