summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-08-27 17:24:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-29 13:56:50 +0100
commitfe2e53ba30ba679c038bd5b48b9a91a41af4c49e (patch)
tree2a86f1fa56d21c7c712f8723485d5a1e386ecc24 /bitbake
parent69955c7b4218c51e1905c683757788af883a421b (diff)
downloadast2050-yocto-poky-fe2e53ba30ba679c038bd5b48b9a91a41af4c49e.zip
ast2050-yocto-poky-fe2e53ba30ba679c038bd5b48b9a91a41af4c49e.tar.gz
bitbake: toaster: create Build methods for calculating progress and ETA
We move the code to calculate build progress as percent and the ETA of the build to the model, so that they can be reused across different pages. (Bitbake rev: c2ced09e7ea4a1762d2788bb12a761734d20fd8e) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/orm/models.py18
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py13
2 files changed, 19 insertions, 12 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 5a6dcd7..bb921fc 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -120,6 +120,24 @@ class Build(models.Model):
build_name = models.CharField(max_length=100)
bitbake_version = models.CharField(max_length=50)
+ def completeper(self):
+ tf = Task.objects.filter(build = self)
+ tfc = tf.count()
+ if tfc > 0:
+ completeper = tf.exclude(order__isnull=True).count()*100/tf.count()
+ else:
+ completeper = 0
+ return completeper
+
+ def eta(self):
+ from django.utils import timezone
+ eta = 0
+ completeper = self.completeper()
+ if self.completeper() > 0:
+ eta = timezone.now() + ((timezone.now() - self.started_on)*(100-completeper)/completeper)
+ return eta
+
+
def get_sorted_target_list(self):
tgts = Target.objects.filter(build_id = self.id).order_by( 'target' );
return( tgts );
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index e68f8b0..86a34ad 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -224,17 +224,6 @@ def builds(request):
# build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
build_mru = Build.objects.filter(completed_on__gte=(timezone.now()-timedelta(hours=24))).order_by("-started_on")[:3]
- for b in [ x for x in build_mru if x.outcome == Build.IN_PROGRESS ]:
- tf = Task.objects.filter(build = b)
- tfc = tf.count()
- if tfc > 0:
- b.completeper = tf.exclude(order__isnull=True).count()*100/tf.count()
- else:
- b.completeper = 0
-
- b.eta = 0
- if b.completeper > 0:
- b.eta = timezone.now() + ((timezone.now() - b.started_on)*(100-b.completeper)/b.completeper)
# set up list of fstypes for each build
fstypes_map = {};
@@ -1854,7 +1843,7 @@ if toastermain.settings.MANAGED:
context = {
"project" : prj,
#"buildrequests" : prj.buildrequest_set.filter(state=BuildRequest.REQ_QUEUED),
- "buildrequests" : map(lambda x: (x, {"machine" : x.brvariable_set.filter(name="MACHINE")[0]}), prj.buildrequest_set.order_by("-pk")),
+ "buildrequests" : map(lambda x: (x, {"machine" : x.brvariable_set.filter(name="MACHINE")[0]}), prj.buildrequest_set.filter(state__lt = BuildRequest.REQ_INPROGRESS).order_by("-pk")),
"builds" : prj.build_set.all(),
"puser": puser,
}
OpenPOWER on IntegriCloud