Show stdout and stderr log of post script using msger
authorYeongil Jang <yg0577.jang@samsung.com>
Thu, 10 Jan 2013 12:42:21 +0000 (21:42 +0900)
committerGui Chen <gui.chen@intel.com>
Wed, 19 Jun 2013 07:53:33 +0000 (03:53 -0400)
 - Msger can't show and recode stdout and stderr log of post script
 because subprocess excuted post script with sys.stdout and sys.stderr.
 Then mic get the log using subprocess pipe and show log using msger.

Signed-off-by: Yeongil Jang <yg0577.jang@samsung.com>
mic/imager/baseimager.py

index 4a501dd..7a765c3 100644 (file)
@@ -1016,11 +1016,13 @@ class BaseImageCreator(object):
 
             try:
                 try:
-                    subprocess.call([s.interp, script],
-                                    preexec_fn = preexec,
-                                    env = env,
-                                    stdout = sys.stdout,
-                                    stderr = sys.stderr)
+                    p = subprocess.Popen([s.interp, script],
+                                       preexec_fn = preexec,
+                                       env = env,
+                                       stdout = subprocess.PIPE,
+                                       stderr = subprocess.STDOUT)
+                    for entry in p.communicate()[0].splitlines():
+                        msger.info(entry)
                 except OSError, (err, msg):
                     raise CreatorError("Failed to execute %%post script "
                                        "with '%s' : %s" % (s.interp, msg))