From patchwork Thu May 19 06:52:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 68088 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3032468qge; Wed, 18 May 2016 23:52:20 -0700 (PDT) X-Received: by 10.194.203.105 with SMTP id kp9mr12076816wjc.70.1463640740765; Wed, 18 May 2016 23:52:20 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id tc14si15819406wjb.21.2016.05.18.23.52.20; Wed, 18 May 2016 23:52:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5AD82A7534; Thu, 19 May 2016 08:52:11 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Hysfda2XjGZl; Thu, 19 May 2016 08:52:11 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4C416A760D; Thu, 19 May 2016 08:51:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 29092A7534 for ; Thu, 19 May 2016 08:51:31 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hVHxsXQzISh9 for ; Thu, 19 May 2016 08:51:31 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by theia.denx.de (Postfix) with ESMTPS id 304A3A74F1 for ; Thu, 19 May 2016 08:51:29 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id u4J6p2Zr001067; Thu, 19 May 2016 15:51:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com u4J6p2Zr001067 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1463640673; bh=AUVWcd+ZG+tpWNwR7jhslrEcPqBuBqgHZVCKEbn7Spc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VMLXOK8A26OUHYaa8+mjHiQHu+8FtAx/gQjBUvcsbj8IOmnV5MvP4SxOsa+cMDP5W jIhM5/g2ettzxrZ7l4+AcYPx+zzaMjuRyI3DdIgZkd7LDKiEke/ApM7siI2T0a96kd OSE2mBLYu7GoBSYGLk7lJfFDk2uOX34eBHPsOnX6m5BYy2Lb8ptDK++dKJSUjigYnN sT5V7vwg35G113U9EafpHnxs5HRi77d79yaNIYBZ8rwXRjhSGTmCp8BHl8C5vAuhLW keuJ6yHn2Qlgf5NgZ4mvudbolMa/rggaKAtuMkIejMYuEZgYzSHqeVj7b4QZCz984w o/JTVA+ORYpcQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 19 May 2016 15:52:02 +0900 Message-Id: <1463640729-25666-15-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463640729-25666-1-git-send-email-yamada.masahiro@socionext.com> References: <1463640729-25666-1-git-send-email-yamada.masahiro@socionext.com> Cc: Joe Hershberger Subject: [U-Boot] [PATCH 14/21] tools: moveconfig: display log atomically in more readable format X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Before this commit, the log was displayed in the format: : : : When we move multiple CONFIGs at the same time, we see as many strings as actions for every defconfig, which is redundant information. Moreover, since normal log and error log are displayed separately, Messages from different threads could be mixed, like this: : : : : : This commit makes sure to call "print" once a defconfig, which enables atomic logging for each defconfig. It also makes it possible to refactor the log format as follows: Signed-off-by: Masahiro Yamada --- tools/moveconfig.py | 73 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 31 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 96ada0d..cf4004f 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -30,13 +30,17 @@ The tool walks through all the defconfig files and move the given CONFIGs. The log is also displayed on the terminal. -Each line is printed in the format - : +The log is printed for each defconfig as follows: - is the name of the defconfig -(without the suffix _defconfig). + + + + + ... - shows what the tool did for that defconfig. + is the name of the defconfig. + + shows what the tool did for that defconfig. It looks like one of the followings: - Move 'CONFIG_... ' @@ -274,15 +278,13 @@ def get_make_cmd(): def color_text(color_enabled, color, string): """Return colored string.""" if color_enabled: - return '\033[' + color + 'm' + string + '\033[0m' + # LF should not be surrounded by the escape sequence. + # Otherwise, additional whitespace or line-feed might be printed. + return '\n'.join([ '\033[' + color + 'm' + s + '\033[0m' if s else '' + for s in string.split('\n') ]) else: return string -def log_msg(color_enabled, color, defconfig, msg): - """Return the formated line for the log.""" - return defconfig[:-len('_defconfig')].ljust(37) + ': ' + \ - color_text(color_enabled, color, msg) + '\n' - def update_cross_compile(color_enabled): """Update per-arch CROSS_COMPILE via environment variables @@ -508,7 +510,7 @@ class KconfigParser: return (ACTION_MOVE, new_val) - def update_dotconfig(self, defconfig): + def update_dotconfig(self): """Parse files for the config options and update the .config. This function parses the generated .config and include/autoconf.mk @@ -551,7 +553,7 @@ class KconfigParser: else: sys.exit("Internal Error. This should not happen.") - log += log_msg(self.options.color, log_color, defconfig, actlog) + log += color_text(self.options.color, log_color, actlog) + '\n' with open(self.dotconfig, 'a') as f: for (action, value) in results: @@ -634,6 +636,7 @@ class Slot: stderr=subprocess.PIPE) self.defconfig = defconfig self.state = STATE_DEFCONFIG + self.log = '' return True def poll(self): @@ -656,14 +659,12 @@ class Slot: return False if self.ps.poll() != 0: - print >> sys.stderr, log_msg(self.options.color, COLOR_LIGHT_RED, - self.defconfig, "Failed to process."), + self.log += color_text(self.options.color, COLOR_LIGHT_RED, + "Failed to process.\n") if self.options.verbose: - print >> sys.stderr, color_text(self.options.color, - COLOR_LIGHT_CYAN, - self.ps.stderr.read()) - self.progress.inc() - self.progress.show() + self.log += color_text(self.options.color, COLOR_LIGHT_CYAN, + self.ps.stderr.read()) + self.show_log(sys.stderr) if self.options.exit_on_error: sys.exit("Exit on error.") # If --exit-on-error flag is not set, skip this board and continue. @@ -673,7 +674,7 @@ class Slot: return True if self.state == STATE_AUTOCONF: - self.log = self.parser.update_dotconfig(self.defconfig) + self.log += self.parser.update_dotconfig() """Save off the defconfig in a consistent way""" cmd = list(self.make_cmd) @@ -687,21 +688,15 @@ class Slot: if not self.options.dry_run: shutil.move(os.path.join(self.build_dir, 'defconfig'), os.path.join('configs', self.defconfig)) - # Some threads are running in parallel. - # Print log in one shot to not mix up logs from different threads. - print self.log, - self.progress.inc() - self.progress.show() + self.show_log() self.state = STATE_IDLE return True self.cross_compile = self.parser.get_cross_compile() if self.cross_compile is None: - print >> sys.stderr, log_msg(self.options.color, COLOR_YELLOW, - self.defconfig, - "Compiler is missing. Do nothing."), - self.progress.inc() - self.progress.show() + self.log += color_text(self.options.color, COLOR_YELLOW, + "Compiler is missing. Do nothing.\n") + self.show_log(sys.stderr) if self.options.exit_on_error: sys.exit("Exit on error.") # If --exit-on-error flag is not set, skip this board and continue. @@ -720,6 +715,22 @@ class Slot: self.state = STATE_AUTOCONF return False + def show_log(self, file=sys.stdout): + """Display log along with progress. + + Arguments: + file: A file object to which the log string is sent. + """ + # output at least 30 characters to hide the "* defconfigs out of *". + log = self.defconfig.ljust(30) + '\n' + + log += '\n'.join([ ' ' + s for s in self.log.split('\n') ]) + # Some threads are running in parallel. + # Print log atomically to not mix up logs from different threads. + print >> file, log + self.progress.inc() + self.progress.show() + def get_failed_boards(self): """Returns a list of failed boards (defconfigs) in this slot. """