Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 09E6BE00BD0; Wed, 21 Jun 2017 15:49:04 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [147.11.146.13 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id E2993E00B8B for ; Wed, 21 Jun 2017 15:49:02 -0700 (PDT) Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id v5LMn1VP001855 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL) for ; Wed, 21 Jun 2017 15:49:01 -0700 (PDT) Received: from ala-dreyna-lx3.corp.ad.wrs.com (147.11.200.76) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server (TLS) id 14.3.294.0; Wed, 21 Jun 2017 15:49:01 -0700 From: David Reyna To: Date: Wed, 21 Jun 2017 15:40:17 -0700 Message-ID: <1498084817-23047-1-git-send-email-david.reyna@windriver.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [147.11.200.76] Subject: [PATCH] toaster: git clone progress bar X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 22:49:04 -0000 Content-Type: text/plain From: David Reyna This adds a clone progress bar If a project has a lot of additional layers, the build may appear to hang while those layers are checked out. This patch adds a clone progress bar that is visible before the parsing progress appears. [YOCTO #9916] Signed-off-by: David Reyna --- .../toaster/bldcontrol/localhostbecontroller.py | 14 +++++++++++ .../toaster/orm/migrations/0016_clone_progress.py | 24 ++++++++++++++++++ bitbake/lib/toaster/orm/models.py | 15 +++++++++++ .../lib/toaster/toastergui/static/js/mrbsection.js | 15 +++++++++++ .../toaster/toastergui/templates/mrb_section.html | 29 +++++++++++++++++++++- bitbake/lib/toaster/toastergui/widgets.py | 4 +++ 6 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 bitbake/lib/toaster/orm/migrations/0016_clone_progress.py diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index 62e62fe..b6224f8 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py @@ -33,6 +33,8 @@ import subprocess from toastermain import settings from bldcontrol.bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException, BitbakeController +import bb.event +import time ##### import logging logger = logging.getLogger("toaster") @@ -85,6 +87,11 @@ class LocalhostBEController(BuildEnvironmentController): return local_checkout_path + def setCloneStatus(self,bitbake,status,total,current): + bitbake.req.build.repos_cloned=current + bitbake.req.build.repos_to_clone=total + bitbake.req.build.save() + def setLayers(self, bitbake, layers, targets): """ a word of attention: by convention, the first layer for any build will be poky! """ @@ -147,7 +154,13 @@ class LocalhostBEController(BuildEnvironmentController): logger.info("Using pre-checked out source for layer %s", cached_layers) # 3. checkout the repositories + clone_count=0 + clone_total=len(gitrepos.keys()) + self.setCloneStatus(bitbake,'Started',clone_total,clone_count) for giturl, commit in gitrepos.keys(): + self.setCloneStatus(bitbake,'progress',clone_total,clone_count) + clone_count += 1 + localdirname = os.path.join(self.be.sourcedir, self.getGitCloneDirectory(giturl, commit)) logger.debug("localhostbecontroller: giturl %s:%s checking out in current directory %s" % (giturl, commit, localdirname)) @@ -198,6 +211,7 @@ class LocalhostBEController(BuildEnvironmentController): if name != "bitbake": layerlist.append(localdirpath.rstrip("/")) + self.setCloneStatus(bitbake,'complete',clone_total,clone_count) logger.debug("localhostbecontroller: current layer list %s " % pformat(layerlist)) # 5. create custom layer and add custom recipes to it diff --git a/bitbake/lib/toaster/orm/migrations/0016_clone_progress.py b/bitbake/lib/toaster/orm/migrations/0016_clone_progress.py new file mode 100644 index 0000000..852b878 --- /dev/null +++ b/bitbake/lib/toaster/orm/migrations/0016_clone_progress.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + +class Migration(migrations.Migration): + + dependencies = [ + ('orm', '0015_layer_local_source_dir'), + ] + + operations = [ + migrations.AddField( + model_name='build', + name='repos_cloned', + field=models.IntegerField(default=0), + ), + migrations.AddField( + model_name='build', + name='repos_to_clone', + field=models.IntegerField(default=1), + ), + ] + diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 6c5cfcd..d1f7a11 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -437,6 +437,12 @@ class Build(models.Model): # number of recipes parsed so far for this build recipes_parsed = models.IntegerField(default=0) + # number of repos to clone for this build + repos_to_clone = models.IntegerField(default=1) + + # number of repos cloned so far for this build + repos_cloned = models.IntegerField(default=0) + @staticmethod def get_recent(project=None): """ @@ -667,6 +673,13 @@ class Build(models.Model): else: return False + def is_cloning(self): + """ + True if the build is still cloning repos + """ + return self.outcome == Build.IN_PROGRESS and \ + self.repos_cloned < self.repos_to_clone + def is_parsing(self): """ True if the build is still parsing recipes @@ -698,6 +711,8 @@ class Build(models.Model): return 'Cancelling'; elif self.is_queued(): return 'Queued' + elif self.is_cloning(): + return 'Cloning' elif self.is_parsing(): return 'Parsing' elif self.is_starting(): diff --git a/bitbake/lib/toaster/toastergui/static/js/mrbsection.js b/bitbake/lib/toaster/toastergui/static/js/mrbsection.js index 73d0935..c0c5fa9 100644 --- a/bitbake/lib/toaster/toastergui/static/js/mrbsection.js +++ b/bitbake/lib/toaster/toastergui/static/js/mrbsection.js @@ -61,6 +61,12 @@ function mrbSectionInit(ctx){ return (cached.recipes_parsed_percentage !== build.recipes_parsed_percentage); } + // returns true if the number of repos cloned/to clone changed + function cloneProgressChanged(build) { + var cached = getCached(build); + return (cached.repos_cloned_percentage !== build.repos_cloned_percentage); + } + function refreshMostRecentBuilds(){ libtoaster.getMostRecentBuilds( libtoaster.ctx.mostRecentBuildsUrl, @@ -100,6 +106,15 @@ function mrbSectionInit(ctx){ container.html(html); } + else if (cloneProgressChanged(build)) { + // update the clone progress text + selector = '#repos-cloned-percentage-' + build.id; + $(selector).html(build.repos_cloned_percentage); + + // update the recipe progress bar + selector = '#repos-cloned-percentage-bar-' + build.id; + $(selector).width(build.repos_cloned_percentage + '%'); + } else if (tasksProgressChanged(build)) { // update the task progress text selector = '#build-pc-done-' + build.id; diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html index b761ffe..c5b9fe9 100644 --- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html +++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html @@ -64,7 +64,9 @@
- <%if state == 'Parsing'%> + <%if state == 'Cloning'%> + <%include tmpl='#cloning-repos-build-template'/%> + <%else state == 'Parsing'%> <%include tmpl='#parsing-recipes-build-template'/%> <%else state == 'Queued'%> <%include tmpl='#queued-build-template'/%> @@ -98,6 +100,31 @@
+ + +