[bitbake-devel] [PATCH 6/9] toaster: regex alternation filter caused django error

Alex DAMIAN alexandru.damian at intel.com
Wed Apr 9 13:17:37 UTC 2014


From: David Reyna <David.Reyna at windriver.com>

The combination of a regex filter specification that uses alternate,
plus a search string, plus multiple search_allowed_fields, leads to
a Django fatal error. Replace this regex filter for variables in
local files with a simpler 'contains' against the project's directory
plus a '/conf/' string.

Alex rebased this on top of fix for #6048.

[YOCTO #5962]

Signed-off-by: David Reyna <David.Reyna at windriver.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
 lib/toaster/toastergui/templatetags/projecttags.py |  6 +++---
 lib/toaster/toastergui/views.py                    | 10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/toaster/toastergui/templatetags/projecttags.py b/lib/toaster/toastergui/templatetags/projecttags.py
index aa1ebf8..e863457 100644
--- a/lib/toaster/toastergui/templatetags/projecttags.py
+++ b/lib/toaster/toastergui/templatetags/projecttags.py
@@ -163,7 +163,7 @@ def filter_setin_files(file_list,matchstr):
     # match only filters
     if search == '':
         for i in range(len(file_list)):   
-            if file_list[i].file_name.find(filter) >= 0:
+            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
@@ -171,7 +171,7 @@ def filter_setin_files(file_list,matchstr):
     # match only search string, plus always last file
     if filter == "":
         for i in range(len(file_list)-1):   
-            if file_list[i].file_name.find(search) >= 0:
+            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:
@@ -180,7 +180,7 @@ def filter_setin_files(file_list,matchstr):
        
     # match filter or search string
     for i in range(len(file_list)):   
-        if (file_list[i].file_name.find(filter) >= 0) or (file_list[i].file_name.find(search) >= 0):
+        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
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 4ed9940..78726a8 100644
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -1154,17 +1154,17 @@ def configvars(request, build_id):
 
     variables = _build_page_range(Paginator(queryset, request.GET.get('count', 50)), request.GET.get('page', 1))
 
+    # show all matching files (not just the last one)
     file_filter= search_term + ":"
-    if filter_string.find('conf/local.conf') > 0:
-        file_filter += 'conf/local.conf'
-    if filter_string.find('conf/bblayers.conf') > 0:
-        file_filter += 'conf/bblayers.conf'
+    if filter_string.find('/conf/') > 0:
+        file_filter += 'conf/(local|bblayers).conf'
     if filter_string.find('conf/machine/') > 0:
         file_filter += 'conf/machine/'
     if filter_string.find('conf/distro/') > 0:
         file_filter += 'conf/distro/'
     if filter_string.find('/bitbake.conf') > 0:
         file_filter += '/bitbake.conf'
+    build_dir=re.sub("/tmp/log/.*","",Build.objects.filter(pk=build_id)[0].cooker_log_path)
 
     context = {
                 'objectname': 'configvars',
@@ -1193,7 +1193,7 @@ def configvars(request, build_id):
                     'class' : 'vhistory__file_name',
                     'label': 'Show:',
                     'options' : [
-                               ('Local configuration variables', 'vhistory__file_name__regex:conf/(local|bblayers).conf', queryset_with_search.filter(vhistory__file_name__regex='conf/(local|bblayers).conf').count(), 'Select this filter to see variables set by the <code>local.conf</code> and <code>bblayers.conf</code> configuration files inside the <code>/build/conf/</code> directory'),
+                               ('Local configuration variables', 'vhistory__file_name__contains:'+build_dir+'/conf/',queryset_with_search.filter(vhistory__file_name__contains=build_dir+'/conf/').count(), 'Select this filter to see variables set by the <code>local.conf</code> and <code>bblayers.conf</code> configuration files inside the <code>/build/conf/</code> directory'),
                                ('Machine configuration variables', 'vhistory__file_name__contains:conf/machine/',queryset_with_search.filter(vhistory__file_name__contains='conf/machine').count(), 'Select this filter to see variables set by the configuration file(s) inside your layers <code>/conf/machine/</code> directory'),
                                ('Distro configuration variables', 'vhistory__file_name__contains:conf/distro/',queryset_with_search.filter(vhistory__file_name__contains='conf/distro').count(), 'Select this filter to see variables set by the configuration file(s) inside your layers <code>/conf/distro/</code> directory'),
                                ('Layer configuration variables', 'vhistory__file_name__contains:conf/layer.conf',queryset_with_search.filter(vhistory__file_name__contains='conf/layer.conf').count(), 'Select this filter to see variables set by the <code>layer.conf</code> configuration file inside your layers'),
-- 
1.9.1




More information about the bitbake-devel mailing list