summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-08-18 17:28:51 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 18:05:53 +0100
commitd18e6303a0bbfcac14766749c4fc8e41478f6db6 (patch)
treecb31a2bab189456a7fd79b8f4253a72e2e67c913 /bitbake/lib
parent504396f6a35e1a18d852f2387098ba7f8f298d3d (diff)
downloadpoky-d18e6303a0bbfcac14766749c4fc8e41478f6db6.tar.gz
bitbake: toaster: models field initialization
As prompted by pylint, the object fields need to be initialized properly, so this patch fixes that. Also adds some casts to int, because, sometimes, the IntegerField is not returning an int, but a string. (Bitbake rev: cc9ac01d0726203fbe916cec51cc464eaeae9305) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/orm/models.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 6b485d2ac4..26abf370d9 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -472,20 +472,27 @@ class Task(models.Model):
472 472
473 search_allowed_fields = [ "recipe__name", "recipe__version", "task_name", "logfile" ] 473 search_allowed_fields = [ "recipe__name", "recipe__version", "task_name", "logfile" ]
474 474
475 def __init__(self, *args, **kwargs):
476 super(Task, self).__init__(*args, **kwargs)
477 try:
478 self._helptext = HelpText.objects.get(key=self.task_name, area=HelpText.VARIABLE, build=self.build).text
479 except HelpText.DoesNotExist:
480 self._helptext = None
481
475 def get_related_setscene(self): 482 def get_related_setscene(self):
476 return Task.objects.filter(task_executed=True, build = self.build, recipe = self.recipe, task_name=self.task_name+"_setscene") 483 return Task.objects.filter(task_executed=True, build = self.build, recipe = self.recipe, task_name=self.task_name+"_setscene")
477 484
478 def get_outcome_text(self): 485 def get_outcome_text(self):
479 return Task.TASK_OUTCOME[self.outcome + 1][1] 486 return Task.TASK_OUTCOME[int(self.outcome) + 1][1]
480 487
481 def get_outcome_help(self): 488 def get_outcome_help(self):
482 return Task.TASK_OUTCOME_HELP[self.outcome][1] 489 return Task.TASK_OUTCOME_HELP[int(self.outcome)][1]
483 490
484 def get_sstate_text(self): 491 def get_sstate_text(self):
485 if self.sstate_result==Task.SSTATE_NA: 492 if self.sstate_result==Task.SSTATE_NA:
486 return '' 493 return ''
487 else: 494 else:
488 return Task.SSTATE_RESULT[self.sstate_result][1] 495 return Task.SSTATE_RESULT[int(self.sstate_result)][1]
489 496
490 def get_executed_display(self): 497 def get_executed_display(self):
491 if self.task_executed: 498 if self.task_executed:
@@ -493,13 +500,6 @@ class Task(models.Model):
493 return "Not Executed" 500 return "Not Executed"
494 501
495 def get_description(self): 502 def get_description(self):
496 if '_helptext' in vars(self) and self._helptext != None:
497 return self._helptext
498 try:
499 self._helptext = HelpText.objects.get(key=self.task_name, area=HelpText.VARIABLE, build=self.build).text
500 except HelpText.DoesNotExist:
501 self._helptext = None
502
503 return self._helptext 503 return self._helptext
504 504
505 build = models.ForeignKey(Build, related_name='task_build') 505 build = models.ForeignKey(Build, related_name='task_build')
@@ -721,13 +721,8 @@ class LayerSource(models.Model):
721 sourcetype = models.IntegerField(choices=SOURCE_TYPE) 721 sourcetype = models.IntegerField(choices=SOURCE_TYPE)
722 apiurl = models.CharField(max_length=255, null=True, default=None) 722 apiurl = models.CharField(max_length=255, null=True, default=None)
723 723
724 def update(self): 724 def __init__(self, *args, **kwargs):
725 """ 725 super(LayerSource, self).__init__(*args, **kwargs)
726 Updates the local database information from the upstream layer source
727 """
728 raise Exception("Abstract, update() must be implemented by all LayerSource-derived classes (object is %s)" % str(vars(self)))
729
730 def save(self, *args, **kwargs):
731 if self.sourcetype == LayerSource.TYPE_LOCAL: 726 if self.sourcetype == LayerSource.TYPE_LOCAL:
732 self.__class__ = LocalLayerSource 727 self.__class__ = LocalLayerSource
733 elif self.sourcetype == LayerSource.TYPE_LAYERINDEX: 728 elif self.sourcetype == LayerSource.TYPE_LAYERINDEX:
@@ -736,6 +731,15 @@ class LayerSource(models.Model):
736 self.__class__ = ImportedLayerSource 731 self.__class__ = ImportedLayerSource
737 elif self.sourcetype == None: 732 elif self.sourcetype == None:
738 raise Exception("Unknown LayerSource-derived class. If you added a new layer source type, fill out all code stubs.") 733 raise Exception("Unknown LayerSource-derived class. If you added a new layer source type, fill out all code stubs.")
734
735
736 def update(self):
737 """
738 Updates the local database information from the upstream layer source
739 """
740 raise Exception("Abstract, update() must be implemented by all LayerSource-derived classes (object is %s)" % str(vars(self)))
741
742 def save(self, *args, **kwargs):
739 return super(LayerSource, self).save(*args, **kwargs) 743 return super(LayerSource, self).save(*args, **kwargs)
740 744
741 def get_object(self): 745 def get_object(self):