Always disable logstderr and flush message buffer in disable_logstderr
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 30 Jan 2012 09:24:15 +0000 (17:24 +0800)
committerJF Ding <jian-feng.ding@intel.com>
Mon, 30 Jan 2012 09:19:50 +0000 (17:19 +0800)
mic/msger.py
plugins/backend/yumpkgmgr.py

index 5f02c29..f3780e4 100644 (file)
@@ -269,6 +269,7 @@ def disable_logstderr():
     global CATCHERR_BUFFILE_PATH
     global CATCHERR_SAVED_2
 
+    raw(msg = None) # flush message buffer and print it.
     os.dup2(CATCHERR_SAVED_2, 2)
     os.close(CATCHERR_SAVED_2)
     os.close(CATCHERR_BUFFILE_FD)
index 9a259b8..ed6732b 100644 (file)
@@ -332,16 +332,16 @@ class Yum(BackendPlugin, yum.YumBase):
             msger.warning('\nCaution, do NOT interrupt the installation, else mic cannot finish the cleanup.')
             installlogfile = "%s/__catched_stderr.buf" % (self.instroot)
             msger.enable_logstderr(installlogfile)
-            ret = self.runTransaction(cb)
+            self.runTransaction(cb)
             self._cleanupRpmdbLocks(self.conf.installroot)
-            msger.disable_logstderr()
-            return ret
         except rpmUtils.RpmUtilsError, e:
             raise CreatorError("mic does NOT support delta rpm: %s" % e)
         except yum.Errors.RepoError, e:
             raise CreatorError("Unable to download from repo : %s" % e)
         except yum.Errors.YumBaseError, e:
             raise CreatorError("Unable to install: %s" % e)
+        finally:
+            msger.disable_logstderr()
 
     def getAllContent(self):
         return self.__pkgs_content