diff options
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 34d37542e1..f5c600ba9f 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -25,6 +25,7 @@ from django.utils import timezone | |||
25 | 25 | ||
26 | 26 | ||
27 | from django.core import validators | 27 | from django.core import validators |
28 | from django.conf import settings | ||
28 | 29 | ||
29 | class GitURLValidator(validators.URLValidator): | 30 | class GitURLValidator(validators.URLValidator): |
30 | import re | 31 | import re |
@@ -183,6 +184,28 @@ class Build(models.Model): | |||
183 | return self.logmessage_set.filter(level=LogMessage.EXCEPTION) | 184 | return self.logmessage_set.filter(level=LogMessage.EXCEPTION) |
184 | 185 | ||
185 | 186 | ||
187 | # an Artifact is anything that results from a Build, and may be of interest to the user, and is not stored elsewhere | ||
188 | class BuildArtifact(models.Model): | ||
189 | build = models.ForeignKey(Build) | ||
190 | file_name = models.FilePathField() | ||
191 | file_size = models.IntegerField() | ||
192 | |||
193 | |||
194 | def get_local_file_name(self): | ||
195 | try: | ||
196 | deploydir = Variable.objects.get(build = self.build, variable_name="DEPLOY_DIR").variable_value | ||
197 | return self.file_name[len(deploydir)+1:] | ||
198 | except: | ||
199 | raise | ||
200 | |||
201 | return self.file_name | ||
202 | |||
203 | |||
204 | def is_available(self): | ||
205 | if settings.MANAGED and build.project is not None: | ||
206 | return build.buildrequest.environment.has_artifact(file_path) | ||
207 | return False | ||
208 | |||
186 | class ProjectTarget(models.Model): | 209 | class ProjectTarget(models.Model): |
187 | project = models.ForeignKey(Project) | 210 | project = models.ForeignKey(Project) |
188 | target = models.CharField(max_length=100) | 211 | target = models.CharField(max_length=100) |
@@ -457,6 +480,12 @@ class Recipe(models.Model): | |||
457 | def __unicode__(self): | 480 | def __unicode__(self): |
458 | return "Recipe " + self.name + ":" + self.version | 481 | return "Recipe " + self.name + ":" + self.version |
459 | 482 | ||
483 | def get_local_path(self): | ||
484 | if settings.MANAGED and self.layer_version.build.project is not None: | ||
485 | return self.file_path[len(self.layer_version.layer.local_path)+1:] | ||
486 | |||
487 | return self.file_path | ||
488 | |||
460 | class Meta: | 489 | class Meta: |
461 | unique_together = ("layer_version", "file_path") | 490 | unique_together = ("layer_version", "file_path") |
462 | 491 | ||