From patchwork Thu May 19 06:52:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 68090 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3032646qge; Wed, 18 May 2016 23:52:41 -0700 (PDT) X-Received: by 10.28.213.1 with SMTP id m1mr34406837wmg.103.1463640761346; Wed, 18 May 2016 23:52:41 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id q68si16396697wme.33.2016.05.18.23.52.41; Wed, 18 May 2016 23:52:41 -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 9F98EA762A; Thu, 19 May 2016 08:52:24 +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 bauuDmPoaUqe; Thu, 19 May 2016 08:52:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 85C0EA762D; Thu, 19 May 2016 08:51:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 254B0A7532 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 Y5HVLHd-AZuk 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 20789A74EE 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 u4J6p2Zs001067; Thu, 19 May 2016 15:51:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com u4J6p2Zs001067 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1463640674; bh=A3KpapfeQhmhA0lY5anZ30+oybYpHZx1Ih858HPzopA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wmoBzkrcMo7mjCghI6RsMlMTZJWXyP9kBSvwZdXfksaIVFafoXz06mEtz0rbFMK5D fbI8Bi2didOza0BT62+rzORdFAenM3/w4bSy3RZIBJ6QmBBpgbLW321NOzsFkNfjYn F3kxRAEKt12Nv2pY0cx1TDIKvJNCSYUFmcaztkGkVHObLp02B+pWiUXAyyq5EUpBko Zbxenj989D/z6Ml57BkFqYIkPyQ5fQ4iVk9zZcM+EDJeNomV8+AZo8KmT2Qebxjl4+ hUHEd1qYXrwDTGO5t27pWR4RxdIoAH+7v+SXhDNdAGb0zaQgPX/SGZmA09dG2/OpJE ww/0kA1+HfprQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 19 May 2016 15:52:03 +0900 Message-Id: <1463640729-25666-16-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 15/21] tools: moveconfig: refactor code to go back to idle state 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" Move similar code to finish() function. Signed-off-by: Masahiro Yamada --- tools/moveconfig.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 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 cf4004f..da7120d 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -664,13 +664,7 @@ class Slot: if self.options.verbose: 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. - # Record the failed board. - self.failed_boards.append(self.defconfig) - self.state = STATE_IDLE + self.finish(False) return True if self.state == STATE_AUTOCONF: @@ -688,21 +682,14 @@ class Slot: if not self.options.dry_run: shutil.move(os.path.join(self.build_dir, 'defconfig'), os.path.join('configs', self.defconfig)) - self.show_log() - self.state = STATE_IDLE + self.finish(True) return True self.cross_compile = self.parser.get_cross_compile() if self.cross_compile is None: 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. - # Record the failed board. - self.failed_boards.append(self.defconfig) - self.state = STATE_IDLE + self.finish(False) return True cmd = list(self.make_cmd) @@ -715,11 +702,12 @@ class Slot: self.state = STATE_AUTOCONF return False - def show_log(self, file=sys.stdout): - """Display log along with progress. + def finish(self, success): + """Display log along with progress and go to the idle state. Arguments: - file: A file object to which the log string is sent. + success: Should be True when the defconfig was processed + successfully, or False when it fails. """ # output at least 30 characters to hide the "* defconfigs out of *". log = self.defconfig.ljust(30) + '\n' @@ -727,9 +715,18 @@ class Slot: 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 + print >> (sys.stdout if success else sys.stderr), log + + if not success: + if self.options.exit_on_error: + sys.exit("Exit on error.") + # If --exit-on-error flag is not set, skip this board and continue. + # Record the failed board. + self.failed_boards.append(self.defconfig) + self.progress.inc() self.progress.show() + self.state = STATE_IDLE def get_failed_boards(self): """Returns a list of failed boards (defconfigs) in this slot.