From: Gui Chen Date: Tue, 21 Aug 2012 15:29:01 +0000 (+0800) Subject: handle logfile to record bootstrap output when specified X-Git-Tag: 0.15~64^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf16f628f25d987df8484d440e41fadbcfdb5d8a;p=platform%2Fupstream%2Fmic.git handle logfile to record bootstrap output when specified Signed-off-by: Gui Chen --- diff --git a/mic/bootstrap.py b/mic/bootstrap.py index 503193d..0b3902c 100644 --- a/mic/bootstrap.py +++ b/mic/bootstrap.py @@ -152,6 +152,7 @@ class Bootstrap(object): self.rootdir = rootdir self.distro = distro self.arch = arch + self.logfile = None self.pkgslist = [] self.repomd = None @@ -208,6 +209,8 @@ class Bootstrap(object): except (OSError, IOError), err: raise RuntimeError(err) finally: + if self.logfile: + msger.log(file(self.logfile).read()) cleanup_chrootenv(self.rootdir, bindmounts, gloablmounts) proxy.unset_proxy_environ() return retcode diff --git a/mic/msger.py b/mic/msger.py index ab94e9e..5deb6bb 100644 --- a/mic/msger.py +++ b/mic/msger.py @@ -179,6 +179,12 @@ def set_interactive(mode=True): else: INTERACTIVE = False +def log(msg=''): + # log msg to LOG_CONTENT then save to logfile + global LOG_CONTENT + if msg: + LOG_CONTENT += msg + def raw(msg=''): _general_print('', NO_COLOR, msg) diff --git a/mic/rt_util.py b/mic/rt_util.py index 3875744..f538271 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -57,6 +57,7 @@ def bootstrap_mic(argv=None): # create bootstrap and run mic in bootstrap bsenv = bootstrap.Bootstrap(rootdir, distro, cropts['arch']) + bsenv.logfile = cropts['logfile'] try: msger.info("Creating %s bootstrap ..." % distro) bsenv.create(cropts['repomd'], pkglist)