Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 2668CE0086E; Mon, 23 May 2016 13:44:30 -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=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FSL_HELO_HOME,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.1 X-Spam-HAM-Report: * 1.0 FSL_HELO_HOME FSL_HELO_HOME * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [74.125.82.47 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 311A7E007E4 for ; Mon, 23 May 2016 13:44:23 -0700 (PDT) Received: by mail-wm0-f47.google.com with SMTP id n129so98034887wmn.1 for ; Mon, 23 May 2016 13:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BmQHrP6fqL+BwEHmt1D4RUA5WwJV8Y7mmc+jmGoKNNQ=; b=tXwzCPxe0pW42dvyLrMKyX2yZfvJBeMfaU8MFo3SWbxdMa4wdh3NLcKFg9NT0U5E7+ KhvQ2jYcBtQmNH+l4m7ULNz5/leH8SaUnRR0OhNY7nf6zyQCOV7pLSL4KVmp0TonB0re 6YmzeIkEKhF9ZNWWuutEicixbX9Ke3iUCVwMnf9bGctsz3XGmqS691CU1mvg11JEEsdf 0stmO5P4VabmW8qGvg19OcSQUb7kCWxjGPyNSpkkGHVM8vQJEfIONr6iUEPNgEhBZah8 YRoeahdtPCVIEIDyLldtsAjNhebhHxmBWkH4xvoHkrj24uUHegcvjrp3GFDxpW613pbb hKCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BmQHrP6fqL+BwEHmt1D4RUA5WwJV8Y7mmc+jmGoKNNQ=; b=Z9aUCN/a3qJc4VobVkXfsyVq7QgEofP9yXWU1ARt1O5NxAsuIpPUmxGq2kmL4cfLVr 1E0c65czo7MYgiXTml9AQWyp6d6KjfHge3EqpbqipiJeDvA55LY3sswNOgEFs0ixt3D6 d4OTdKdEnTCEHFVSGa9Bq+UZEja/AiXiL1UUQJ9K+kMBH16EcCkL+Nc6s6DwsxvyT9G4 R4+xgK68hAwF86RT98XKZLFvfRe2A4FbsDfpZfu1vHgqb3pTCdxWK6mTh5Bbr1pJhg/F 9S5vigmG/tRyjjT2eLUQ4OhWkMFc4QWufvvlGwQGk0JjTNWV3dR+o68gXRjKJdrDGk3z XO4g== X-Gm-Message-State: ALyK8tKb7IndzZxi4t0D8T+f/9gSaYtNxo5sC6AbQMy7s2HLJUZSmWHah6rCM94Z52joJfAG X-Received: by 10.194.58.8 with SMTP id m8mr718471wjq.98.1464036262735; Mon, 23 May 2016 13:44:22 -0700 (PDT) Received: from orion.home (host31-48-249-108.range31-48.btcentralplus.com. [31.48.249.108]) by smtp.gmail.com with ESMTPSA id h14sm12035619wme.1.2016.05.23.13.44.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 May 2016 13:44:22 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Mon, 23 May 2016 21:44:12 +0100 Message-Id: <1464036257-23434-3-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1464036257-23434-1-git-send-email-michael.g.wood@intel.com> References: <1464036257-23434-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 2/7] toaster: port table for Built packages to ToasterTable 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: Mon, 23 May 2016 20:44:30 -0000 This is the table that displays all the packages built in the build. Build -> Packages. Adds a template snippet for the git revision popover. Signed-off-by: Michael Wood --- bitbake/lib/toaster/toastergui/buildtables.py | 152 +++++++++++++++++++++ bitbake/lib/toaster/toastergui/tables.py | 10 +- .../toastergui/templates/basebuildpage.html | 26 ++-- .../lib/toaster/toastergui/templates/bpackage.html | 108 --------------- .../templates/buildinfo-toastertable.html | 23 ++++ .../templates/snippets/gitrev_popover.html | 8 ++ bitbake/lib/toaster/toastergui/urls.py | 7 +- bitbake/lib/toaster/toastergui/views.py | 90 ------------ 8 files changed, 203 insertions(+), 221 deletions(-) create mode 100644 bitbake/lib/toaster/toastergui/buildtables.py delete mode 100644 bitbake/lib/toaster/toastergui/templates/bpackage.html create mode 100644 bitbake/lib/toaster/toastergui/templates/buildinfo-toastertable.html create mode 100644 bitbake/lib/toaster/toastergui/templates/snippets/gitrev_popover.html diff --git a/bitbake/lib/toaster/toastergui/buildtables.py b/bitbake/lib/toaster/toastergui/buildtables.py new file mode 100644 index 0000000..cf07ea8 --- /dev/null +++ b/bitbake/lib/toaster/toastergui/buildtables.py @@ -0,0 +1,152 @@ +# +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# BitBake Toaster Implementation +# +# Copyright (C) 2016 Intel Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +from orm.models import Build +import toastergui.tables as tables + +from toastergui.widgets import ToasterTable + + +class BuildTablesMixin(ToasterTable): + def get_context_data(self, **kwargs): + # We need to be explicit about which superclass we're calling here + # Otherwise the MRO gets in a right mess + context = ToasterTable.get_context_data(self, **kwargs) + context['build'] = Build.objects.get(pk=kwargs['build_id']) + return context + + +class BuiltPackagesTableBase(tables.PackagesTable): + """ Table to display all the packages built in a build """ + def __init__(self, *args, **kwargs): + super(BuiltPackagesTableBase, self).__init__(*args, **kwargs) + self.title = "Packages built" + self.default_orderby = "name" + + def setup_queryset(self, *args, **kwargs): + build = Build.objects.get(pk=kwargs['build_id']) + self.static_context_extra['build'] = build + self.queryset = build.package_set.all().exclude(recipe=None) + self.queryset = self.queryset.order_by(self.default_orderby) + + def setup_columns(self, *args, **kwargs): + super(BuiltPackagesTableBase, self).setup_columns(*args, **kwargs) + + def pkg_link_template(val): + """ return the template used for the link with the val as the + element value i.e. inside the """ + + return (''' + %s + ''' % val) + + def recipe_link_template(val): + return (''' + {%% if data.recipe %%} + %(value)s + {%% else %%} + %(value)s + {%% endif %%} + ''' % {'value': val}) + + add_pkg_link_to = ['name', 'version', 'size', 'license'] + add_recipe_link_to = ['recipe__name', 'recipe__version'] + + # Add the recipe and pkg build links to the required columns + for column in self.columns: + # Convert to template field style accessors + tmplv = column['field_name'].replace('__', '.') + tmplv = "{{data.%s}}" % tmplv + + if column['field_name'] in add_pkg_link_to: + # Don't overwrite an existing template + if column['static_data_template']: + column['static_data_template'] =\ + pkg_link_template(column['static_data_template']) + else: + column['static_data_template'] = pkg_link_template(tmplv) + + column['static_data_name'] = column['field_name'] + + elif column['field_name'] in add_recipe_link_to: + # Don't overwrite an existing template + if column['static_data_template']: + column['static_data_template'] =\ + recipe_link_template(column['static_data_template']) + else: + column['static_data_template'] =\ + recipe_link_template(tmplv) + column['static_data_name'] = column['field_name'] + + self.add_column(title="Layer", + field_name="recipe__layer_version__layer__name", + hidden=True, + orderable=True) + + self.add_column(title="Layer branch", + field_name="recipe__layer_version__branch", + hidden=True, + orderable=True) + + git_rev_template = ''' + {% with vcs_ref=data.recipe.layer_version.commit %} + {% include 'snippets/gitrev_popover.html' %} + {% endwith %} + ''' + + self.add_column(title="Layer commit", + static_data_name='vcs_ref', + static_data_template=git_rev_template, + hidden=True) + + +class BuiltPackagesTable(BuildTablesMixin, BuiltPackagesTableBase): + """ Show all the packages built for the selected build """ + def __init__(self, *args, **kwargs): + super(BuiltPackagesTable, self).__init__(*args, **kwargs) + self.title = "Packages built" + self.default_orderby = "name" + + self.empty_state =\ + ('No packages were built. How did this happen?' + 'Well, BitBake reuses as much stuff as possible.' + 'If all of the packages needed were already built and available' + 'in your build infrastructure, BitBake' + 'will not rebuild any of them. This might be slightly confusing,' + 'but it does make everything faster.') + + def setup_columns(self, *args, **kwargs): + super(BuiltPackagesTable, self).setup_columns(*args, **kwargs) + + def remove_dep_cols(columns): + for column in columns: + # We don't need these fields + if column['static_data_name'] in ['reverse_dependencies', + 'dependencies']: + continue + + yield column + + self.columns = list(remove_dep_cols(self.columns)) diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index 29b68de..39d3f93 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py @@ -146,15 +146,8 @@ class LayersTable(ToasterTable): static_data_template=git_dir_template) revision_template = ''' - {% load projecttags %} {% with vcs_ref=data.get_vcs_reference %} - {% if vcs_ref|is_shaid %} - - {{vcs_ref|truncatechars:10}} - - {% else %} - {{vcs_ref}} - {% endif %} + {% include 'snippets/gitrev_popover.html' %} {% endwith %} ''' @@ -699,6 +692,7 @@ class PackagesTable(ToasterTable): self.add_column(title="Approx Size", orderable=True, + field_name="size", static_data_name="size", static_data_template="{% load projecttags %} \ {{data.size|filtered_filesizeformat}}") diff --git a/bitbake/lib/toaster/toastergui/templates/basebuildpage.html b/bitbake/lib/toaster/toastergui/templates/basebuildpage.html index 0d8c882..52a32b6 100644 --- a/bitbake/lib/toaster/toastergui/templates/basebuildpage.html +++ b/bitbake/lib/toaster/toastergui/templates/basebuildpage.html @@ -21,10 +21,19 @@ {% block localbreadcrumb %}{% endblock %} @@ -32,7 +41,7 @@