summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r--bitbake/lib/toaster/orm/models.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 61f6a2072e..0443a4589d 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -436,17 +436,32 @@ class Build(models.Model):
436 eta += ((eta - self.started_on)*(100-completeper))/completeper 436 eta += ((eta - self.started_on)*(100-completeper))/completeper
437 return eta 437 return eta
438 438
439 def has_images(self):
440 """
441 Returns True if at least one of the targets for this build has an
442 image file associated with it, False otherwise
443 """
444 targets = Target.objects.filter(build_id=self.id)
445 has_images = False
446 for target in targets:
447 if target.has_images():
448 has_images = True
449 break
450 return has_images
451
439 def get_image_file_extensions(self): 452 def get_image_file_extensions(self):
440 """ 453 """
441 Get list of file name extensions for images produced by this build; 454 Get string of file name extensions for images produced by this build;
442 note that this is the actual list of extensions stored on Target objects 455 note that this is the actual list of extensions stored on Target objects
443 for this build, and not the value of IMAGE_FSTYPES. 456 for this build, and not the value of IMAGE_FSTYPES.
457
458 Returns comma-separated string, e.g. "vmdk, ext4"
444 """ 459 """
445 extensions = [] 460 extensions = []
446 461
447 targets = Target.objects.filter(build_id = self.id) 462 targets = Target.objects.filter(build_id = self.id)
448 for target in targets: 463 for target in targets:
449 if (not target.is_image): 464 if not target.is_image:
450 continue 465 continue
451 466
452 target_image_files = Target_Image_File.objects.filter( 467 target_image_files = Target_Image_File.objects.filter(
@@ -739,6 +754,12 @@ class Target(models.Model):
739 sdk_file.target = self 754 sdk_file.target = self
740 sdk_file.save() 755 sdk_file.save()
741 756
757 def has_images(self):
758 """
759 Returns True if this target has one or more image files attached to it.
760 """
761 return self.target_image_file_set.all().count() > 0
762
742# kernel artifacts for a target: bzImage and modules* 763# kernel artifacts for a target: bzImage and modules*
743class TargetKernelFile(models.Model): 764class TargetKernelFile(models.Model):
744 target = models.ForeignKey(Target) 765 target = models.ForeignKey(Target)
@@ -775,6 +796,9 @@ class Target_Image_File(models.Model):
775 796
776 @property 797 @property
777 def suffix(self): 798 def suffix(self):
799 """
800 Suffix for image file, minus leading "."
801 """
778 for suffix in Target_Image_File.SUFFIXES: 802 for suffix in Target_Image_File.SUFFIXES:
779 if self.file_name.endswith(suffix): 803 if self.file_name.endswith(suffix):
780 return suffix 804 return suffix