diff options
| author | Elliot Smith <elliot.smith@intel.com> | 2015-10-14 15:43:44 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-16 14:13:22 +0100 |
| commit | 026e9812648e9d43b3fcfce8aab1cd8e843246a2 (patch) | |
| tree | 660c538d9978537baed3f47155f742d57f98159c | |
| parent | 1feeb8e4991dc2f2a2b85b4b544ad36e96dc4a0b (diff) | |
| download | poky-026e9812648e9d43b3fcfce8aab1cd8e843246a2.tar.gz | |
bitbake: toaster: Check whether buildrequest exists before using it
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]
(Bitbake rev: af33409612139ab2347baf6b847b23faea19752d)
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | bitbake/lib/toaster/orm/models.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 1cbf480acd..44a453a58c 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
| @@ -344,6 +344,9 @@ class Build(models.Model): | |||
| 344 | tgts = Target.objects.filter(build_id = self.id).order_by( 'target' ); | 344 | tgts = Target.objects.filter(build_id = self.id).order_by( 'target' ); |
| 345 | return( tgts ); | 345 | return( tgts ); |
| 346 | 346 | ||
| 347 | def get_outcome_text(self): | ||
| 348 | return Build.BUILD_OUTCOME[int(self.outcome)][1] | ||
| 349 | |||
| 347 | @property | 350 | @property |
| 348 | def toaster_exceptions(self): | 351 | def toaster_exceptions(self): |
| 349 | return self.logmessage_set.filter(level=LogMessage.EXCEPTION) | 352 | return self.logmessage_set.filter(level=LogMessage.EXCEPTION) |
| @@ -361,10 +364,23 @@ class Build(models.Model): | |||
| 361 | return (self.completed_on - self.started_on).total_seconds() | 364 | return (self.completed_on - self.started_on).total_seconds() |
| 362 | 365 | ||
| 363 | def get_current_status(self): | 366 | def get_current_status(self): |
| 367 | """ | ||
| 368 | get the status string from the build request if the build | ||
| 369 | has one, or the text for the build outcome if it doesn't | ||
| 370 | """ | ||
| 371 | |||
| 364 | from bldcontrol.models import BuildRequest | 372 | from bldcontrol.models import BuildRequest |
| 365 | if self.outcome == Build.IN_PROGRESS and self.buildrequest.state != BuildRequest.REQ_INPROGRESS: | 373 | |
| 374 | build_request = None | ||
| 375 | if hasattr(self, 'buildrequest'): | ||
| 376 | build_request = self.buildrequest | ||
| 377 | |||
| 378 | if (build_request | ||
| 379 | and build_request.state != BuildRequest.REQ_INPROGRESS | ||
| 380 | and self.outcome == Build.IN_PROGRESS): | ||
| 366 | return self.buildrequest.get_state_display() | 381 | return self.buildrequest.get_state_display() |
| 367 | return self.get_outcome_display() | 382 | else: |
| 383 | return self.get_outcome_text() | ||
| 368 | 384 | ||
| 369 | def __str__(self): | 385 | def __str__(self): |
| 370 | return "%d %s %s" % (self.id, self.project, ",".join([t.target for t in self.target_set.all()])) | 386 | return "%d %s %s" % (self.id, self.project, ",".join([t.target for t in self.target_set.all()])) |
