Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 7F661E00CEA; Tue, 29 Sep 2015 08:42:05 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [192.55.52.93 listed in list.dnswl.org] Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 452A4E00CD8 for ; Tue, 29 Sep 2015 08:41:56 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 29 Sep 2015 08:41:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,608,1437462000"; d="scan'208";a="815398574" Received: from aaronmux-mobl.ger.corp.intel.com (HELO lp.ger.corp.intel.com) ([10.252.5.249]) by fmsmga002.fm.intel.com with ESMTP; 29 Sep 2015 08:41:56 -0700 From: Elliot Smith To: toaster@yoctoproject.org Date: Tue, 29 Sep 2015 16:41:44 +0100 Message-Id: <1443541306-12019-3-git-send-email-elliot.smith@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1443541306-12019-1-git-send-email-elliot.smith@intel.com> References: <1443541306-12019-1-git-send-email-elliot.smith@intel.com> Subject: [review-request][PATCH 2/4] toaster: Check whether buildrequest exists before using it X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2015 15:42:05 -0000 Builds initiated from the command line don't have a buildrequest associated with them. The build.buildrequest association is only added if a build is triggered from toaster. Some of the code for displaying the status of a build refers to build.buildrequest without checking whether it has been set, which causes an error to be thrown. Add a guard to check whether the buildrequest has been set. [YOCTO #8277] Signed-off-by: Elliot Smith --- bitbake/lib/toaster/orm/models.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 5aed158..3ea821d 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -344,6 +344,9 @@ class Build(models.Model): tgts = Target.objects.filter(build_id = self.id).order_by( 'target' ); return( tgts ); + def get_outcome_text(self): + return Build.BUILD_OUTCOME[int(self.outcome)][1] + @property def toaster_exceptions(self): return self.logmessage_set.filter(level=LogMessage.EXCEPTION) @@ -361,10 +364,23 @@ class Build(models.Model): return (self.completed_on - self.started_on).total_seconds() def get_current_status(self): + """ + get the status string from the build request if the build + has one, or the text for the build outcome if it doesn't + """ + from bldcontrol.models import BuildRequest - if self.outcome == Build.IN_PROGRESS and self.buildrequest.state != BuildRequest.REQ_INPROGRESS: + + build_request = None + if hasattr(self, 'buildrequest'): + build_request = self.buildrequest + + if (build_request + and build_request.state != BuildRequest.REQ_INPROGRESS + and self.outcome == Build.IN_PROGRESS): return self.buildrequest.get_state_display() - return self.get_outcome_display() + else: + return self.get_outcome_text() def __str__(self): return "%d %s %s" % (self.id, self.project, ",".join([t.target for t in self.target_set.all()])) -- Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.