1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 00:39:46 +00:00

bitbake: toastergui: show relative paths in configvars view

Reworked filtering of config paths.

Stripped clone paths, topdir and its parent directory from the paths
to config files in configvars view.

[YOCTO #7463]

(Bitbake rev: 873087b11653848ec2704d67de5680a265b71eaa)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ed Bartosh
2015-05-18 12:03:00 +03:00
committed by Richard Purdie
parent 9dcfa32cf1
commit 6a9efefbba
3 changed files with 40 additions and 61 deletions
@@ -54,9 +54,11 @@
<td class="variable_name"><a data-toggle="modal" href="#variable-{{variable.pk}}">{{variable.variable_name}}</a></td> <td class="variable_name"><a data-toggle="modal" href="#variable-{{variable.pk}}">{{variable.variable_name}}</a></td>
<td class="variable_value"><a data-toggle="modal" href="#variable-{{variable.pk}}">{{variable.variable_value|truncatechars:153}}</a></td> <td class="variable_value"><a data-toggle="modal" href="#variable-{{variable.pk}}">{{variable.variable_value|truncatechars:153}}</a></td>
<td class="file"><a data-toggle="modal" href="#variable-{{variable.pk}}"> <td class="file"><a data-toggle="modal" href="#variable-{{variable.pk}}">
{% if variable.vhistory.all %} {% autoescape off %} {% if variable.vhistory.all %}
{{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}} {% for path in variable.vhistory.all|filter_setin_files:file_filter %}
{% endautoescape %} {% endif %} {{path|cut_path_prefix:dirstostrip}}<p>
{% endfor %}
{% endif %}
</a></td> </a></td>
<td class="description"> <td class="description">
{% if variable.description %} {% if variable.description %}
@@ -115,7 +117,7 @@
<tbody> <tbody>
{% for vh in variable.vhistory.all %} {% for vh in variable.vhistory.all %}
<tr> <tr>
<td>{{forloop.counter}}</td><td>{{vh.file_name|cut_layer_path_prefix:layer_names}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td> <td>{{forloop.counter}}</td><td>{{vh.file_name|cut_path_prefix:dirstostrip}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
</tr> </tr>
{%endfor%} {%endfor%}
</tbody> </tbody>
@@ -20,6 +20,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from datetime import datetime, timedelta from datetime import datetime, timedelta
from os.path import relpath
import re import re
from django import template from django import template
from django.utils import timezone from django.utils import timezone
@@ -182,47 +183,23 @@ def variable_parent_name(value):
return re.sub('_[a-z].*', '', value) return re.sub('_[a-z].*', '', value)
@register.filter @register.filter
def filter_setin_files(file_list,matchstr): def filter_setin_files(file_list, matchstr):
""" filter/search the 'set in' file lists. Note """Filter/search the 'set in' file lists."""
that this output is not autoescaped to allow result = []
the <p> marks, but this is safe as the data search, filter = matchstr.split(':')
is file paths 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 filters, show last file (if any) # no filter, show last file (if any)
if matchstr == ":": last = list(file_list)[-1].file_name
if file_list: if not filter and last not in result:
return file_list[len(file_list)-1].file_name result.append(last)
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 + "<p>") < 0:
htmlstr += file_list[i].file_name + "<p>"
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 + "<p>") < 0:
htmlstr += file_list[i].file_name + "<p>"
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 + "<p>") < 0:
htmlstr += file_list[i].file_name + "<p>"
return htmlstr
return result
@register.filter @register.filter
def string_slice(strvar,slicevar): def string_slice(strvar,slicevar):
@@ -313,16 +290,9 @@ def is_shaid(text):
return False return False
@register.filter @register.filter
def cut_layer_path_prefix(fullpath,layer_names): def cut_path_prefix(fullpath, prefixes):
### if some part of the full local path to a layer matches """Cut path prefix from fullpath."""
### an entry in layer_names (sorted desc), return the layer for prefix in prefixes:
### name relative path. if fullpath.startswith(prefix):
for lname in layer_names: return relpath(fullpath, prefix)
# 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]
return fullpath return fullpath
+13 -6
View File
@@ -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 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 Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency
from orm.models import Target_Installed_Package, Target_File, Target_Image_File, BuildArtifact 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.views.decorators.cache import cache_control
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.exceptions import MultipleObjectsReturned from django.core.exceptions import MultipleObjectsReturned
@@ -39,6 +41,7 @@ from datetime import timedelta, datetime, date
from django.utils import formats from django.utils import formats
from toastergui.templatetags.projecttags import json as jsonfilter from toastergui.templatetags.projecttags import json as jsonfilter
import json import json
from os.path import dirname
# all new sessions should come through the landing page; # all new sessions should come through the landing page;
# determine in which mode we are running in, and redirect appropriately # determine in which mode we are running in, and redirect appropriately
@@ -1300,11 +1303,6 @@ def configvars(request, build_id):
variables = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1)) 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) # show all matching files (not just the last one)
file_filter= search_term + ":" file_filter= search_term + ":"
if filter_string.find('/conf/') > 0: if filter_string.find('/conf/') > 0:
@@ -1317,6 +1315,15 @@ def configvars(request, build_id):
file_filter += '/bitbake.conf' file_filter += '/bitbake.conf'
build_dir=re.sub("/tmp/log/.*","",Build.objects.get(pk=build_id).cooker_log_path) 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 = { context = {
'objectname': 'configvars', 'objectname': 'configvars',
'object_search_display':'BitBake variables', 'object_search_display':'BitBake variables',
@@ -1327,7 +1334,7 @@ def configvars(request, build_id):
'total_count':queryset_with_search.count(), 'total_count':queryset_with_search.count(),
'default_orderby' : 'variable_name:+', 'default_orderby' : 'variable_name:+',
'search_term':search_term, '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 # Specifies the display of columns for the table, appearance in "Edit columns" box, toggling default show/hide, and specifying filters for columns
'tablecols' : [ 'tablecols' : [
{'name': 'Variable', {'name': 'Variable',