configurationengine/source/plugins/common/ConeCommandPlugin/commandplugin/commandml.py
changeset 9 63964d875993
parent 4 0951727b8815
--- a/configurationengine/source/plugins/common/ConeCommandPlugin/commandplugin/commandml.py	Tue Oct 26 10:43:50 2010 +0100
+++ b/configurationengine/source/plugins/common/ConeCommandPlugin/commandplugin/commandml.py	Sat Nov 06 16:59:14 2010 +0200
@@ -25,7 +25,7 @@
 import logging
 import types
 import pkg_resources
-
+import sys 
 import subprocess
 
 from cone.public import plugin,utils
@@ -331,7 +331,7 @@
         self.cwd = None
         self.envs = None
         self.arguments = []
-        self.pipes = {}
+        self.pipes = {'stdout': subprocess.PIPE, 'stderr': subprocess.PIPE}
         self.streams = {}
         self.filters = []
         self.logger = None
@@ -457,8 +457,15 @@
                 pid = subprocess.Popen(command_str, shell=self.shell, env=env_dict, cwd=cwd,\
                                           bufsize=self.bufsize, stdin = self.get_pipe("stdin", 'r'),\
                                           stdout = self.get_pipe("stdout"), stderr = self.get_pipe("stderr"))
+                
+                #log stdout and stderr to logger
+                stdout_value, stderr_value = pid.communicate()
+                if stdout_value != None: self.logger.info("stdout: %s" % stdout_value)
+                if stderr_value != None: self.logger.warning("stderr: %s" % stderr_value)
+                
                 #Waiting for process to complete
                 retcode = pid.wait()
+                
                 #Storing stream information for possible further processing.
                 self.set_streams(pid.stdin, pid.stdout, pid.stderr)