From: Faiyaz Ahmed <faiyaza@cs.princeton.edu>
Date: Fri, 27 Mar 2009 19:50:29 +0000 (+0000)
Subject: change from call()/check_call to Popen() in log_exec.  This will raise and log an... 
X-Git-Tag: NodeManager-1.8-8~30
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=e889161ded9e959582ece2e56b01d43f6a8d6db8;p=nodemanager.git

change from call()/check_call to Popen() in log_exec.  This will raise and log an exception when spawned processes barf.  nm.daemon should now be empty :-D
---

diff --git a/logger.py b/logger.py
index 3fedde9..17ae04c 100644
--- a/logger.py
+++ b/logger.py
@@ -43,7 +43,12 @@ def log(msg,level=LOG_NODE):
 
 def log_call(*args):
     log('running command %s' % ' '.join(args))
-    try: subprocess.check_call(args, close_fds=True)
+    try: 
+        child = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
+        child.wait() # wait for proc to hang up
+        if child.returncode:
+                raise Exception("command failed:\n stdout - %s\n stderr - %s" % \
+                        (child.stdout.readlines(), child.stderr.readlines()))
     except: log_exc()
 
 def log_exc(name = None):