From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id AD137E0086D; Mon, 18 May 2015 03:56:44 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [192.55.52.115 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 38543E007B6 for ; Mon, 18 May 2015 03:56:42 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 18 May 2015 03:56:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,453,1427785200"; d="scan'208";a="573017924" Received: from linux.intel.com ([10.23.219.25]) by orsmga003.jf.intel.com with ESMTP; 18 May 2015 03:56:33 -0700 Received: from vmed.fi.intel.com (vmed.fi.intel.com [10.237.72.65]) by linux.intel.com (Postfix) with ESMTP id DB7046A408F; Mon, 18 May 2015 03:56:02 -0700 (PDT) From: Ed Bartosh To: toaster@yoctoproject.org Date: Mon, 18 May 2015 12:03:00 +0300 Message-Id: <1431939780-30209-1-git-send-email-ed.bartosh@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [review-request][PATCH v6] bitbake: toastergui: show relative paths in configvars view 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, 18 May 2015 10:56:44 -0000 Reworked filtering of config paths. Stripped clone paths, topdir and its parent directory from the paths to config files in configvars view. [YOCTO #7463] Signed-off-by: Ed Bartosh --- .../toaster/toastergui/templates/configvars.html | 10 +-- .../toaster/toastergui/templatetags/projecttags.py | 76 +++++++--------------- bitbake/lib/toaster/toastergui/views.py | 19 ++++-- 3 files changed, 42 insertions(+), 63 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html b/bitbake/lib/toaster/toastergui/templates/configvars.html index 3e4c7e8..42c42a5 100644 --- a/bitbake/lib/toaster/toastergui/templates/configvars.html +++ b/bitbake/lib/toaster/toastergui/templates/configvars.html @@ -54,9 +54,11 @@ {{variable.variable_name}} {{variable.variable_value|truncatechars:153}} - {% if variable.vhistory.all %} {% autoescape off %} - {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}} - {% endautoescape %} {% endif %} + {% if variable.vhistory.all %} + {% for path in variable.vhistory.all|filter_setin_files:file_filter %} + {{path|cut_path_prefix:dirstostrip}}

+ {% endfor %} + {% endif %} {% if variable.description %} @@ -115,7 +117,7 @@ {% for vh in variable.vhistory.all %} - {{forloop.counter}}{{vh.file_name|cut_layer_path_prefix:layer_names}}{{vh.operation}}{{vh.line_number}} + {{forloop.counter}}{{vh.file_name|cut_path_prefix:dirstostrip}}{{vh.operation}}{{vh.line_number}} {%endfor%} diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py index 54700e3..1bc3bc2 100644 --- a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py +++ b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py @@ -20,6 +20,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from datetime import datetime, timedelta +from os.path import relpath import re from django import template from django.utils import timezone @@ -182,47 +183,23 @@ def variable_parent_name(value): return re.sub('_[a-z].*', '', value) @register.filter -def filter_setin_files(file_list,matchstr): - """ filter/search the 'set in' file lists. Note - that this output is not autoescaped to allow - the

marks, but this is safe as the data - is file paths - """ - - # no filters, show last file (if any) - if matchstr == ":": - if file_list: - return file_list[len(file_list)-1].file_name - else: - return '' - - search, filter = matchstr.partition(':')[::2] - htmlstr="" - # match only filters - if search == '': - for i in range(len(file_list)): - if re.search(filter, file_list[i].file_name): - if htmlstr.find(file_list[i].file_name + "

") < 0: - htmlstr += file_list[i].file_name + "

" - return htmlstr - - # match only search string, plus always last file - if filter == "": - for i in range(len(file_list)-1): - if re.search(search,file_list[i].file_name): - if htmlstr.find(file_list[i].file_name + "

") < 0: - htmlstr += file_list[i].file_name + "

" - if htmlstr.find(file_list[len(file_list)-1].file_name) < 0: - htmlstr += file_list[len(file_list)-1].file_name - return htmlstr - - # match filter or search string - for i in range(len(file_list)): - if re.search(filter, file_list[i].file_name) or re.search(search,file_list[i].file_name): - if htmlstr.find(file_list[i].file_name + "

") < 0: - htmlstr += file_list[i].file_name + "

" - return htmlstr - +def filter_setin_files(file_list, matchstr): + """Filter/search the 'set in' file lists.""" + result = [] + search, filter = matchstr.split(':') + for pattern in (search, filter): + if pattern: + for fobj in file_list: + fname = fobj.file_name + if fname not in result and re.search(pattern, fname): + result.append(fname) + + # no filter, show last file (if any) + last = list(file_list)[-1].file_name + if not filter and last not in result: + result.append(last) + + return result @register.filter def string_slice(strvar,slicevar): @@ -313,16 +290,9 @@ def is_shaid(text): return False @register.filter -def cut_layer_path_prefix(fullpath,layer_names): - ### if some part of the full local path to a layer matches - ### an entry in layer_names (sorted desc), return the layer - ### name relative path. - for lname in layer_names: - # import rpdb; rpdb.set_trace() - # only try layer names that are non-trivial to avoid false matches - if len(lname) >= 4: - # match layer name with as a subdir / or for remote layers /_ - if re.search('/' + lname, fullpath) or re.search('/_' + lname, fullpath): - parts = re.split(lname, fullpath, 1) - return lname + parts[1] +def cut_path_prefix(fullpath, prefixes): + """Cut path prefix from fullpath.""" + for prefix in prefixes: + if fullpath.startswith(prefix): + return relpath(fullpath, prefix) return fullpath diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 9217d8a..7f3621d 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -28,6 +28,8 @@ from django.shortcuts import render, redirect from orm.models import Build, Target, Task, Layer, Layer_Version, Recipe, LogMessage, Variable from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency from orm.models import Target_Installed_Package, Target_File, Target_Image_File, BuildArtifact +from bldcontrol.models import BuildEnvironment, BuildRequest +from bldcontrol import bbcontroller from django.views.decorators.cache import cache_control from django.core.urlresolvers import reverse from django.core.exceptions import MultipleObjectsReturned @@ -39,6 +41,7 @@ from datetime import timedelta, datetime, date from django.utils import formats from toastergui.templatetags.projecttags import json as jsonfilter import json +from os.path import dirname # all new sessions should come through the landing page; # determine in which mode we are running in, and redirect appropriately @@ -1298,11 +1301,6 @@ def configvars(request, build_id): variables = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1)) - layers = Layer.objects.filter(layer_version_layer__projectlayer__project__build=build_id).order_by("-name") - layer_names = map(lambda layer : layer.name, layers) - # special case for meta built-in layer - layer_names.append('meta') - # show all matching files (not just the last one) file_filter= search_term + ":" if filter_string.find('/conf/') > 0: @@ -1315,6 +1313,15 @@ def configvars(request, build_id): file_filter += '/bitbake.conf' build_dir=re.sub("/tmp/log/.*","",Build.objects.get(pk=build_id).cooker_log_path) + clones = [] + for breq in BuildRequest.objects.filter(build_id=build_id): + bc = bbcontroller.getBuildEnvironmentController(pk = breq.environment.id) + for brl in breq.brlayer_set.all(): + localdirname = bc.getGitCloneDirectory(brl.giturl, brl.commit) + if not localdirname.startswith("/"): + localdirname = os.path.join(bc.be.sourcedir, localdirname) + clones.append(localdirname) + context = { 'objectname': 'configvars', 'object_search_display':'BitBake variables', @@ -1325,7 +1332,7 @@ def configvars(request, build_id): 'total_count':queryset_with_search.count(), 'default_orderby' : 'variable_name:+', 'search_term':search_term, - 'layer_names' : layer_names, + 'dirstostrip': clones + [dirname(build_dir), dirname(dirname(build_dir))], # Specifies the display of columns for the table, appearance in "Edit columns" box, toggling default show/hide, and specifying filters for columns 'tablecols' : [ {'name': 'Variable', -- 2.1.4