All of lore.kernel.org
 help / color / mirror / Atom feed
* [review-request][PATCH] bitbake: toastergui: show relative paths in configvars view
@ 2015-05-02 10:37 Ed Bartosh
  2015-05-05 10:08 ` Barros Pena, Belen
  0 siblings, 1 reply; 15+ messages in thread
From: Ed Bartosh @ 2015-05-02 10:37 UTC (permalink / raw)
  To: toaster

Strip topdir from paths to config files in configvars view.
Got rid of specific filter cut_layer_path_prefix.

[YOCTO #7463]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 .../lib/toaster/toastergui/templates/configvars.html    |  4 ++--
 .../lib/toaster/toastergui/templatetags/projecttags.py  | 17 ++++-------------
 bitbake/lib/toaster/toastergui/views.py                 |  8 ++------
 3 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html b/bitbake/lib/toaster/toastergui/templates/configvars.html
index 3e4c7e8..42d8fa7 100644
--- a/bitbake/lib/toaster/toastergui/templates/configvars.html
+++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
@@ -55,7 +55,7 @@
         <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}}">
             {% if variable.vhistory.all %} {% autoescape off %}
-                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}}
+                {{variable.vhistory.all | filter_setin_files:file_filter | cut_path_prefix:topdir}}
             {% endautoescape %} {% endif %}
         </a></td>
         <td class="description">
@@ -115,7 +115,7 @@
                 <tbody>
                     {% for vh in variable.vhistory.all %}
                     <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:topdir}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
                     </tr>
                     {%endfor%}
                 </tbody>
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index 54700e3..4c3bffd 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
@@ -313,16 +314,6 @@ 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]
-    return fullpath
+def cut_path_prefix(fullpath, topdir):
+    """Cut topdir from the fullpath."""
+    return relpath(fullpath, topdir) if fullpath.startswith(topdir) else fullpath
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index b5c4d87..e7110c8 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -39,6 +39,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
@@ -1326,11 +1327,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:
@@ -1353,7 +1349,7 @@ def configvars(request, build_id):
                 'total_count':queryset_with_search.count(),
                 'default_orderby' : 'variable_name:+',
                 'search_term':search_term,
-                'layer_names' : layer_names,
+                'topdir': 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



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [review-request][PATCH] bitbake: toastergui: show relative paths in configvars view
  2015-05-02 10:37 [review-request][PATCH] bitbake: toastergui: show relative paths in configvars view Ed Bartosh
@ 2015-05-05 10:08 ` Barros Pena, Belen
  2015-05-05 12:57   ` [PATCH] " Ed Bartosh
  2015-05-05 12:59   ` [review-request][PATCH] " Ed Bartosh
  0 siblings, 2 replies; 15+ messages in thread
From: Barros Pena, Belen @ 2015-05-05 10:08 UTC (permalink / raw)
  To: Ed Bartosh, toaster


On 02/05/2015 11:37, "Ed Bartosh" <ed.bartosh@linux.intel.com> wrote:

>Strip topdir from paths to config files in configvars view.
>Got rid of specific filter cut_layer_path_prefix.

The paths in the variables table are not looking as expected when I apply
this. The paths to local.conf and bblayers.conf do show now as relative
paths, but paths to files inside a layer become full paths (instead of
relative paths). So instead of seeing

meta/conf/bitbake.conf


I see 

/home/<user>/<poky_dir>/meta/conf/bitbake.conf

I've uploaded an screenshot here

http://imgur.com/BhehRxF


All paths in this table should be relative paths.

Cheers

Belén

>
>[YOCTO #7463]
>
>Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
>---
> .../lib/toaster/toastergui/templates/configvars.html    |  4 ++--
> .../lib/toaster/toastergui/templatetags/projecttags.py  | 17
>++++-------------
> bitbake/lib/toaster/toastergui/views.py                 |  8 ++------
> 3 files changed, 8 insertions(+), 21 deletions(-)
>
>diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html
>b/bitbake/lib/toaster/toastergui/templates/configvars.html
>index 3e4c7e8..42d8fa7 100644
>--- a/bitbake/lib/toaster/toastergui/templates/configvars.html
>+++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
>@@ -55,7 +55,7 @@
>         <td class="variable_value"><a data-toggle="modal"
>href="#variable-{{variable.pk}}">{{variable.variable_value|truncatechars:1
>53}}</a></td>
>         <td class="file"><a data-toggle="modal"
>href="#variable-{{variable.pk}}">
>             {% if variable.vhistory.all %} {% autoescape off %}
>-                {{variable.vhistory.all | filter_setin_files:file_filter
>| cut_layer_path_prefix:layer_names}}
>+                {{variable.vhistory.all | filter_setin_files:file_filter
>| cut_path_prefix:topdir}}
>             {% endautoescape %} {% endif %}
>         </a></td>
>         <td class="description">
>@@ -115,7 +115,7 @@
>                 <tbody>
>                     {% for vh in variable.vhistory.all %}
>                     <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:topdir}}</t
>d><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
>                     </tr>
>                     {%endfor%}
>                 </tbody>
>diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
>b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
>index 54700e3..4c3bffd 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
>@@ -313,16 +314,6 @@ 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]
>-    return fullpath
>+def cut_path_prefix(fullpath, topdir):
>+    """Cut topdir from the fullpath."""
>+    return relpath(fullpath, topdir) if fullpath.startswith(topdir) else
>fullpath
>diff --git a/bitbake/lib/toaster/toastergui/views.py
>b/bitbake/lib/toaster/toastergui/views.py
>index b5c4d87..e7110c8 100755
>--- a/bitbake/lib/toaster/toastergui/views.py
>+++ b/bitbake/lib/toaster/toastergui/views.py
>@@ -39,6 +39,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
>@@ -1326,11 +1327,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=bui
>ld_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:
>@@ -1353,7 +1349,7 @@ def configvars(request, build_id):
>                 'total_count':queryset_with_search.count(),
>                 'default_orderby' : 'variable_name:+',
>                 'search_term':search_term,
>-                'layer_names' : layer_names,
>+                'topdir': 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
>
>-- 
>_______________________________________________
>toaster mailing list
>toaster@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/toaster



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] bitbake: toastergui: show relative paths in configvars view
  2015-05-05 10:08 ` Barros Pena, Belen
@ 2015-05-05 12:57   ` Ed Bartosh
  2015-05-05 14:35     ` Ed Bartosh
  2015-05-05 12:59   ` [review-request][PATCH] " Ed Bartosh
  1 sibling, 1 reply; 15+ messages in thread
From: Ed Bartosh @ 2015-05-05 12:57 UTC (permalink / raw)
  To: openembedded-core

Stripped topdir from paths to config files in configvars view.

[YOCTO #7463]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/templates/configvars.html   | 4 ++--
 bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 6 ++++++
 bitbake/lib/toaster/toastergui/views.py                    | 2 ++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html b/bitbake/lib/toaster/toastergui/templates/configvars.html
index 3e4c7e8..99ffe8b 100644
--- a/bitbake/lib/toaster/toastergui/templates/configvars.html
+++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
@@ -55,7 +55,7 @@
         <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}}">
             {% if variable.vhistory.all %} {% autoescape off %}
-                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}}
+                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names | cut_topdir_path_prefix:topdir}}
             {% endautoescape %} {% endif %}
         </a></td>
         <td class="description">
@@ -115,7 +115,7 @@
                 <tbody>
                     {% for vh in variable.vhistory.all %}
                     <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_layer_path_prefix:layer_names|cut_topdir_path_prefix:topdir}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
                     </tr>
                     {%endfor%}
                 </tbody>
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index 54700e3..67762a5 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
@@ -326,3 +327,8 @@ def cut_layer_path_prefix(fullpath,layer_names):
                 parts = re.split(lname, fullpath, 1)
                 return lname + parts[1]
     return fullpath
+
+@register.filter
+def cut_topdir_path_prefix(fullpath, topdir):
+    """Cut topdir from the fullpath."""
+    return relpath(fullpath, topdir) if fullpath.startswith(topdir) else fullpath
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 7849b50..d2cd367 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -39,6 +39,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
@@ -1326,6 +1327,7 @@ def configvars(request, build_id):
                 'default_orderby' : 'variable_name:+',
                 'search_term':search_term,
                 'layer_names' : layer_names,
+                'topdir': 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



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [review-request][PATCH] bitbake: toastergui: show relative paths in configvars view
  2015-05-05 10:08 ` Barros Pena, Belen
  2015-05-05 12:57   ` [PATCH] " Ed Bartosh
@ 2015-05-05 12:59   ` Ed Bartosh
  2015-05-06 18:03     ` Barros Pena, Belen
  1 sibling, 1 reply; 15+ messages in thread
From: Ed Bartosh @ 2015-05-05 12:59 UTC (permalink / raw)
  To: toaster

Stripped topdir from paths to config files in configvars view.

[YOCTO #7463]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/templates/configvars.html   | 4 ++--
 bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 6 ++++++
 bitbake/lib/toaster/toastergui/views.py                    | 2 ++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html b/bitbake/lib/toaster/toastergui/templates/configvars.html
index 3e4c7e8..99ffe8b 100644
--- a/bitbake/lib/toaster/toastergui/templates/configvars.html
+++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
@@ -55,7 +55,7 @@
         <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}}">
             {% if variable.vhistory.all %} {% autoescape off %}
-                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}}
+                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names | cut_topdir_path_prefix:topdir}}
             {% endautoescape %} {% endif %}
         </a></td>
         <td class="description">
@@ -115,7 +115,7 @@
                 <tbody>
                     {% for vh in variable.vhistory.all %}
                     <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_layer_path_prefix:layer_names|cut_topdir_path_prefix:topdir}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
                     </tr>
                     {%endfor%}
                 </tbody>
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index 54700e3..67762a5 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
@@ -326,3 +327,8 @@ def cut_layer_path_prefix(fullpath,layer_names):
                 parts = re.split(lname, fullpath, 1)
                 return lname + parts[1]
     return fullpath
+
+@register.filter
+def cut_topdir_path_prefix(fullpath, topdir):
+    """Cut topdir from the fullpath."""
+    return relpath(fullpath, topdir) if fullpath.startswith(topdir) else fullpath
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 7849b50..d2cd367 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -39,6 +39,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
@@ -1326,6 +1327,7 @@ def configvars(request, build_id):
                 'default_orderby' : 'variable_name:+',
                 'search_term':search_term,
                 'layer_names' : layer_names,
+                'topdir': 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



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] bitbake: toastergui: show relative paths in configvars view
  2015-05-05 12:57   ` [PATCH] " Ed Bartosh
@ 2015-05-05 14:35     ` Ed Bartosh
  0 siblings, 0 replies; 15+ messages in thread
From: Ed Bartosh @ 2015-05-05 14:35 UTC (permalink / raw)
  To: openembedded-core

On Tue, May 05, 2015 at 03:57:13PM +0300, Ed Bartosh wrote:

Sorry, wrong list. Please ignore.

> Stripped topdir from paths to config files in configvars view.
> 
> [YOCTO #7463]
> 
> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
> ---
>  bitbake/lib/toaster/toastergui/templates/configvars.html   | 4 ++--
>  bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 6 ++++++
>  bitbake/lib/toaster/toastergui/views.py                    | 2 ++
>  3 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html b/bitbake/lib/toaster/toastergui/templates/configvars.html
> index 3e4c7e8..99ffe8b 100644
> --- a/bitbake/lib/toaster/toastergui/templates/configvars.html
> +++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
> @@ -55,7 +55,7 @@
>          <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}}">
>              {% if variable.vhistory.all %} {% autoescape off %}
> -                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}}
> +                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names | cut_topdir_path_prefix:topdir}}
>              {% endautoescape %} {% endif %}
>          </a></td>
>          <td class="description">
> @@ -115,7 +115,7 @@
>                  <tbody>
>                      {% for vh in variable.vhistory.all %}
>                      <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_layer_path_prefix:layer_names|cut_topdir_path_prefix:topdir}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
>                      </tr>
>                      {%endfor%}
>                  </tbody>
> diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
> index 54700e3..67762a5 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
> @@ -326,3 +327,8 @@ def cut_layer_path_prefix(fullpath,layer_names):
>                  parts = re.split(lname, fullpath, 1)
>                  return lname + parts[1]
>      return fullpath
> +
> +@register.filter
> +def cut_topdir_path_prefix(fullpath, topdir):
> +    """Cut topdir from the fullpath."""
> +    return relpath(fullpath, topdir) if fullpath.startswith(topdir) else fullpath
> diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
> index 7849b50..d2cd367 100755
> --- a/bitbake/lib/toaster/toastergui/views.py
> +++ b/bitbake/lib/toaster/toastergui/views.py
> @@ -39,6 +39,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
> @@ -1326,6 +1327,7 @@ def configvars(request, build_id):
>                  'default_orderby' : 'variable_name:+',
>                  'search_term':search_term,
>                  'layer_names' : layer_names,
> +                'topdir': 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
> 

-- 
--
Regards,
Ed


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [review-request][PATCH] bitbake: toastergui: show relative paths in configvars view
  2015-05-05 12:59   ` [review-request][PATCH] " Ed Bartosh
@ 2015-05-06 18:03     ` Barros Pena, Belen
  2015-05-06 21:00       ` [review-request][PATCH v3] " Ed Bartosh
  2015-05-06 21:03       ` [review-request][PATCH v4] " Ed Bartosh
  0 siblings, 2 replies; 15+ messages in thread
From: Barros Pena, Belen @ 2015-05-06 18:03 UTC (permalink / raw)
  To: Ed Bartosh, toaster



On 05/05/2015 13:59, "Ed Bartosh" <ed.bartosh@linux.intel.com> wrote:

>Stripped topdir from paths to config files in configvars view.

Almost! Most paths are now ok, but we still seem to be showing full paths
for files inside the /bitbake directory.

It can be seen quite well it in this screenshot:

http://i.imgur.com/Kk4WmeB.png	

Thanks!!

Belén

>
>[YOCTO #7463]
>
>Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
>---
> bitbake/lib/toaster/toastergui/templates/configvars.html   | 4 ++--
> bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 6 ++++++
> bitbake/lib/toaster/toastergui/views.py                    | 2 ++
> 3 files changed, 10 insertions(+), 2 deletions(-)
>
>diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html
>b/bitbake/lib/toaster/toastergui/templates/configvars.html
>index 3e4c7e8..99ffe8b 100644
>--- a/bitbake/lib/toaster/toastergui/templates/configvars.html
>+++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
>@@ -55,7 +55,7 @@
>         <td class="variable_value"><a data-toggle="modal"
>href="#variable-{{variable.pk}}">{{variable.variable_value|truncatechars:1
>53}}</a></td>
>         <td class="file"><a data-toggle="modal"
>href="#variable-{{variable.pk}}">
>             {% if variable.vhistory.all %} {% autoescape off %}
>-                {{variable.vhistory.all | filter_setin_files:file_filter
>| cut_layer_path_prefix:layer_names}}
>+                {{variable.vhistory.all | filter_setin_files:file_filter
>| cut_layer_path_prefix:layer_names | cut_topdir_path_prefix:topdir}}
>             {% endautoescape %} {% endif %}
>         </a></td>
>         <td class="description">
>@@ -115,7 +115,7 @@
>                 <tbody>
>                     {% for vh in variable.vhistory.all %}
>                     <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_layer_path_prefix:layer
>_names|cut_topdir_path_prefix:topdir}}</td><td>{{vh.operation}}</td><td>{{
>vh.line_number}}</td>
>                     </tr>
>                     {%endfor%}
>                 </tbody>
>diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
>b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
>index 54700e3..67762a5 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
>@@ -326,3 +327,8 @@ def cut_layer_path_prefix(fullpath,layer_names):
>                 parts = re.split(lname, fullpath, 1)
>                 return lname + parts[1]
>     return fullpath
>+
>+@register.filter
>+def cut_topdir_path_prefix(fullpath, topdir):
>+    """Cut topdir from the fullpath."""
>+    return relpath(fullpath, topdir) if fullpath.startswith(topdir) else
>fullpath
>diff --git a/bitbake/lib/toaster/toastergui/views.py
>b/bitbake/lib/toaster/toastergui/views.py
>index 7849b50..d2cd367 100755
>--- a/bitbake/lib/toaster/toastergui/views.py
>+++ b/bitbake/lib/toaster/toastergui/views.py
>@@ -39,6 +39,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
>@@ -1326,6 +1327,7 @@ def configvars(request, build_id):
>                 'default_orderby' : 'variable_name:+',
>                 'search_term':search_term,
>                 'layer_names' : layer_names,
>+                'topdir': 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
>
>-- 
>_______________________________________________
>toaster mailing list
>toaster@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/toaster



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [review-request][PATCH v3] bitbake: toastergui: show relative paths in configvars view
  2015-05-06 18:03     ` Barros Pena, Belen
@ 2015-05-06 21:00       ` Ed Bartosh
  2015-05-06 21:03       ` [review-request][PATCH v4] " Ed Bartosh
  1 sibling, 0 replies; 15+ messages in thread
From: Ed Bartosh @ 2015-05-06 21:00 UTC (permalink / raw)
  To: toaster

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

[YOCTO #7463]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>

tbs

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/templates/configvars.html   | 4 ++--
 bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 9 +++++++++
 bitbake/lib/toaster/toastergui/views.py                    | 2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html b/bitbake/lib/toaster/toastergui/templates/configvars.html
index 3e4c7e8..99ffe8b 100644
--- a/bitbake/lib/toaster/toastergui/templates/configvars.html
+++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
@@ -55,7 +55,7 @@
         <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}}">
             {% if variable.vhistory.all %} {% autoescape off %}
-                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}}
+                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names | cut_topdir_path_prefix:topdir}}
             {% endautoescape %} {% endif %}
         </a></td>
         <td class="description">
@@ -115,7 +115,7 @@
                 <tbody>
                     {% for vh in variable.vhistory.all %}
                     <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_layer_path_prefix:layer_names|cut_topdir_path_prefix:topdir}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
                     </tr>
                     {%endfor%}
                 </tbody>
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index 54700e3..f77e42e 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, dirname
 import re
 from django import template
 from django.utils import timezone
@@ -326,3 +327,11 @@ def cut_layer_path_prefix(fullpath,layer_names):
                 parts = re.split(lname, fullpath, 1)
                 return lname + parts[1]
     return fullpath
+
+@register.filter
+def cut_topdir_path_prefix(fullpath, topdir):
+    """Cut topdir and its parent directory from the fullpath."""
+    for prefix in (topdir, dirname(topdir)):
+        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 7849b50..d2cd367 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -39,6 +39,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
@@ -1326,6 +1327,7 @@ def configvars(request, build_id):
                 'default_orderby' : 'variable_name:+',
                 'search_term':search_term,
                 'layer_names' : layer_names,
+                'topdir': 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



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [review-request][PATCH v4] bitbake: toastergui: show relative paths in configvars view
  2015-05-06 18:03     ` Barros Pena, Belen
  2015-05-06 21:00       ` [review-request][PATCH v3] " Ed Bartosh
@ 2015-05-06 21:03       ` Ed Bartosh
  2015-05-07  9:26         ` Damian, Alexandru
  2015-05-07  9:54         ` Barros Pena, Belen
  1 sibling, 2 replies; 15+ messages in thread
From: Ed Bartosh @ 2015-05-06 21:03 UTC (permalink / raw)
  To: toaster

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

[YOCTO #7463]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/toaster/toastergui/templates/configvars.html   | 4 ++--
 bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 9 +++++++++
 bitbake/lib/toaster/toastergui/views.py                    | 2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html b/bitbake/lib/toaster/toastergui/templates/configvars.html
index 3e4c7e8..99ffe8b 100644
--- a/bitbake/lib/toaster/toastergui/templates/configvars.html
+++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
@@ -55,7 +55,7 @@
         <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}}">
             {% if variable.vhistory.all %} {% autoescape off %}
-                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}}
+                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names | cut_topdir_path_prefix:topdir}}
             {% endautoescape %} {% endif %}
         </a></td>
         <td class="description">
@@ -115,7 +115,7 @@
                 <tbody>
                     {% for vh in variable.vhistory.all %}
                     <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_layer_path_prefix:layer_names|cut_topdir_path_prefix:topdir}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
                     </tr>
                     {%endfor%}
                 </tbody>
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index 54700e3..f77e42e 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, dirname
 import re
 from django import template
 from django.utils import timezone
@@ -326,3 +327,11 @@ def cut_layer_path_prefix(fullpath,layer_names):
                 parts = re.split(lname, fullpath, 1)
                 return lname + parts[1]
     return fullpath
+
+@register.filter
+def cut_topdir_path_prefix(fullpath, topdir):
+    """Cut topdir and its parent directory from the fullpath."""
+    for prefix in (topdir, dirname(topdir)):
+        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 7849b50..d2cd367 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -39,6 +39,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
@@ -1326,6 +1327,7 @@ def configvars(request, build_id):
                 'default_orderby' : 'variable_name:+',
                 'search_term':search_term,
                 'layer_names' : layer_names,
+                'topdir': 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



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [review-request][PATCH v4] bitbake: toastergui: show relative paths in configvars view
  2015-05-06 21:03       ` [review-request][PATCH v4] " Ed Bartosh
@ 2015-05-07  9:26         ` Damian, Alexandru
  2015-05-07  9:54         ` Barros Pena, Belen
  1 sibling, 0 replies; 15+ messages in thread
From: Damian, Alexandru @ 2015-05-07  9:26 UTC (permalink / raw)
  To: Ed Bartosh; +Cc: toaster

[-- Attachment #1: Type: text/plain, Size: 4893 bytes --]

Hi Ed,

Thanks for the patch set - impressive work :).

I would appreciate if, in the future, you could put all patches on a branch
on poky-contrib and mail in the branch name in the subject, such as:

[review-request] branch/name

This would trigger the yocto automated tester which doesn't currently
process individual patches.

Thank you,
Alex

On Wed, May 6, 2015 at 10:03 PM, Ed Bartosh <ed.bartosh@linux.intel.com>
wrote:

> Stripped topdir and its parent directory from paths to
> config files in configvars view.
>
> [YOCTO #7463]
>
> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
> ---
>  bitbake/lib/toaster/toastergui/templates/configvars.html   | 4 ++--
>  bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 9 +++++++++
>  bitbake/lib/toaster/toastergui/views.py                    | 2 ++
>  3 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html
> b/bitbake/lib/toaster/toastergui/templates/configvars.html
> index 3e4c7e8..99ffe8b 100644
> --- a/bitbake/lib/toaster/toastergui/templates/configvars.html
> +++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
> @@ -55,7 +55,7 @@
>          <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}}">
>              {% if variable.vhistory.all %} {% autoescape off %}
> -                {{variable.vhistory.all | filter_setin_files:file_filter
> | cut_layer_path_prefix:layer_names}}
> +                {{variable.vhistory.all | filter_setin_files:file_filter
> | cut_layer_path_prefix:layer_names | cut_topdir_path_prefix:topdir}}
>              {% endautoescape %} {% endif %}
>          </a></td>
>          <td class="description">
> @@ -115,7 +115,7 @@
>                  <tbody>
>                      {% for vh in variable.vhistory.all %}
>                      <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_layer_path_prefix:layer_names|cut_topdir_path_prefix:topdir}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
>                      </tr>
>                      {%endfor%}
>                  </tbody>
> diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
> b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
> index 54700e3..f77e42e 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, dirname
>  import re
>  from django import template
>  from django.utils import timezone
> @@ -326,3 +327,11 @@ def cut_layer_path_prefix(fullpath,layer_names):
>                  parts = re.split(lname, fullpath, 1)
>                  return lname + parts[1]
>      return fullpath
> +
> +@register.filter
> +def cut_topdir_path_prefix(fullpath, topdir):
> +    """Cut topdir and its parent directory from the fullpath."""
> +    for prefix in (topdir, dirname(topdir)):
> +        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 7849b50..d2cd367 100755
> --- a/bitbake/lib/toaster/toastergui/views.py
> +++ b/bitbake/lib/toaster/toastergui/views.py
> @@ -39,6 +39,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
> @@ -1326,6 +1327,7 @@ def configvars(request, build_id):
>                  'default_orderby' : 'variable_name:+',
>                  'search_term':search_term,
>                  'layer_names' : layer_names,
> +                'topdir': 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
>
> --
> _______________________________________________
> toaster mailing list
> toaster@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>



-- 
Alex Damian
Yocto Project
SSG / OTC

[-- Attachment #2: Type: text/html, Size: 7391 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [review-request][PATCH v4] bitbake: toastergui: show relative paths in configvars view
  2015-05-06 21:03       ` [review-request][PATCH v4] " Ed Bartosh
  2015-05-07  9:26         ` Damian, Alexandru
@ 2015-05-07  9:54         ` Barros Pena, Belen
  2015-05-18  8:48           ` [review-request][PATCH v5] " Ed Bartosh
  2015-05-18  9:03           ` [review-request][PATCH v6] " Ed Bartosh
  1 sibling, 2 replies; 15+ messages in thread
From: Barros Pena, Belen @ 2015-05-07  9:54 UTC (permalink / raw)
  To: Ed Bartosh; +Cc: toaster



On 06/05/2015 22:03, "Ed Bartosh" <ed.bartosh@linux.intel.com> wrote:

>Stripped topdir and its parent directory from paths to
>config files in configvars view.

Ed, I am so sorry about this :( But there are still a couple of issues
with the paths:

1. Paths to files inside /bitbake are showing the parent of the /bitbake
directory. Here is an example in the BBFILES variable

http://i.imgur.com/xfUutMN.png


I spoke to Paul Eggleton and he thinks we should be showing that path from
the /bitbake directory. So in the screenshot above, the path should be:

bitbake/lib/bb/cooker.py

2. Something strange is going on when you apply a filter to the table.
It's a bit hard to explain, so this is how to reproduce it.

* Build something. When the build is done, click on the build target name,
then click on 'Configuration' in the left nav.
* Search for 'DISTRO_VERSION'. The path looks as expected.
* Now click on the little filter button in the "Set in file" column
heading. 
* In the options listed, select the radio button for "Distro configuration
variables", then click the "Apply" button

The table shows the paths to the 2 distro files that touched the
DISTRO_VERSION variable: this works as expected. But the second path is
showing in full. However, if you click on the variable name, in the
history the paths display correctly.

This only happens when you use a filter AND a single table cell shows more
than one path. 

I am really sorry about this: didn't think this was going to be so tricky
:/

Cheers

Belén



>
>[YOCTO #7463]
>
>Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
>---
> bitbake/lib/toaster/toastergui/templates/configvars.html   | 4 ++--
> bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 9 +++++++++
> bitbake/lib/toaster/toastergui/views.py                    | 2 ++
> 3 files changed, 13 insertions(+), 2 deletions(-)
>
>diff --git a/bitbake/lib/toaster/toastergui/templates/configvars.html
>b/bitbake/lib/toaster/toastergui/templates/configvars.html
>index 3e4c7e8..99ffe8b 100644
>--- a/bitbake/lib/toaster/toastergui/templates/configvars.html
>+++ b/bitbake/lib/toaster/toastergui/templates/configvars.html
>@@ -55,7 +55,7 @@
>         <td class="variable_value"><a data-toggle="modal"
>href="#variable-{{variable.pk}}">{{variable.variable_value|truncatechars:1
>53}}</a></td>
>         <td class="file"><a data-toggle="modal"
>href="#variable-{{variable.pk}}">
>             {% if variable.vhistory.all %} {% autoescape off %}
>-                {{variable.vhistory.all | filter_setin_files:file_filter
>| cut_layer_path_prefix:layer_names}}
>+                {{variable.vhistory.all | filter_setin_files:file_filter
>| cut_layer_path_prefix:layer_names | cut_topdir_path_prefix:topdir}}
>             {% endautoescape %} {% endif %}
>         </a></td>
>         <td class="description">
>@@ -115,7 +115,7 @@
>                 <tbody>
>                     {% for vh in variable.vhistory.all %}
>                     <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_layer_path_prefix:layer
>_names|cut_topdir_path_prefix:topdir}}</td><td>{{vh.operation}}</td><td>{{
>vh.line_number}}</td>
>                     </tr>
>                     {%endfor%}
>                 </tbody>
>diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
>b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
>index 54700e3..f77e42e 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, dirname
> import re
> from django import template
> from django.utils import timezone
>@@ -326,3 +327,11 @@ def cut_layer_path_prefix(fullpath,layer_names):
>                 parts = re.split(lname, fullpath, 1)
>                 return lname + parts[1]
>     return fullpath
>+
>+@register.filter
>+def cut_topdir_path_prefix(fullpath, topdir):
>+    """Cut topdir and its parent directory from the fullpath."""
>+    for prefix in (topdir, dirname(topdir)):
>+        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 7849b50..d2cd367 100755
>--- a/bitbake/lib/toaster/toastergui/views.py
>+++ b/bitbake/lib/toaster/toastergui/views.py
>@@ -39,6 +39,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
>@@ -1326,6 +1327,7 @@ def configvars(request, build_id):
>                 'default_orderby' : 'variable_name:+',
>                 'search_term':search_term,
>                 'layer_names' : layer_names,
>+                'topdir': 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
>
>-- 
>_______________________________________________
>toaster mailing list
>toaster@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/toaster



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [review-request][PATCH v5] bitbake: toastergui: show relative paths in configvars view
  2015-05-07  9:54         ` Barros Pena, Belen
@ 2015-05-18  8:48           ` Ed Bartosh
  2015-05-18  9:03           ` [review-request][PATCH v6] " Ed Bartosh
  1 sibling, 0 replies; 15+ messages in thread
From: Ed Bartosh @ 2015-05-18  8:48 UTC (permalink / raw)
  To: toaster

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 <ed.bartosh@linux.intel.com>
---
 .../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 @@
         <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="file"><a data-toggle="modal" href="#variable-{{variable.pk}}">
-            {% 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}}<p>
+                {% endfor %}
+            {% endif %}
         </a></td>
         <td class="description">
             {% if variable.description %}
@@ -115,7 +117,7 @@
                 <tbody>
                     {% for vh in variable.vhistory.all %}
                     <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>
                     {%endfor%}
                 </tbody>
diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index 54700e3..15f8fa9 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, dirname
 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 <p> 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 + "<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
-
+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



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [review-request][PATCH v6] bitbake: toastergui: show relative paths in configvars view
  2015-05-07  9:54         ` Barros Pena, Belen
  2015-05-18  8:48           ` [review-request][PATCH v5] " Ed Bartosh
@ 2015-05-18  9:03           ` Ed Bartosh
  2015-05-18 12:41             ` Barros Pena, Belen
  1 sibling, 1 reply; 15+ messages in thread
From: Ed Bartosh @ 2015-05-18  9:03 UTC (permalink / raw)
  To: toaster

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 <ed.bartosh@linux.intel.com>
---
 .../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 @@
         <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="file"><a data-toggle="modal" href="#variable-{{variable.pk}}">
-            {% 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}}<p>
+                {% endfor %}
+            {% endif %}
         </a></td>
         <td class="description">
             {% if variable.description %}
@@ -115,7 +117,7 @@
                 <tbody>
                     {% for vh in variable.vhistory.all %}
                     <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>
                     {%endfor%}
                 </tbody>
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 <p> 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 + "<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
-
+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



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [review-request][PATCH v6] bitbake: toastergui: show relative paths in configvars view
  2015-05-18  9:03           ` [review-request][PATCH v6] " Ed Bartosh
@ 2015-05-18 12:41             ` Barros Pena, Belen
  2015-05-21  9:49               ` Damian, Alexandru
  0 siblings, 1 reply; 15+ messages in thread
From: Barros Pena, Belen @ 2015-05-18 12:41 UTC (permalink / raw)
  To: Ed Bartosh, toaster

On 18/05/2015 10:03, "Ed Bartosh" <ed.bartosh@linux.intel.com> wrote:

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

This works for me. Thanks!

Belén

>
>[YOCTO #7463]
>
>Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
>---
> .../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 @@
>         <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:1
>53}}</a></td>
>         <td class="file"><a data-toggle="modal"
>href="#variable-{{variable.pk}}">
>-            {% 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}}<p>
>+                {% endfor %}
>+            {% endif %}
>         </a></td>
>         <td class="description">
>             {% if variable.description %}
>@@ -115,7 +117,7 @@
>                 <tbody>
>                     {% for vh in variable.vhistory.all %}
>                     <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>
>                     {%endfor%}
>                 </tbody>
>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 <p> 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 + "<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
>-
>+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=bui
>ld_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_lo
>g_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
>
>-- 
>_______________________________________________
>toaster mailing list
>toaster@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/toaster



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [review-request][PATCH v6] bitbake: toastergui: show relative paths in configvars view
  2015-05-18 12:41             ` Barros Pena, Belen
@ 2015-05-21  9:49               ` Damian, Alexandru
  2015-05-21 10:18                 ` Ed Bartosh
  0 siblings, 1 reply; 15+ messages in thread
From: Damian, Alexandru @ 2015-05-21  9:49 UTC (permalink / raw)
  To: Barros Pena, Belen; +Cc: toaster

[-- Attachment #1: Type: text/plain, Size: 10726 bytes --]

Taken for submission,

Can you please post new patches as branches on poky-contrib ?

Thank you,
Alex

On Mon, May 18, 2015 at 1:41 PM, Barros Pena, Belen <
belen.barros.pena@intel.com> wrote:

> On 18/05/2015 10:03, "Ed Bartosh" <ed.bartosh@linux.intel.com> wrote:
>
> >Reworked filtering of config paths.
> >
> >Stripped clone paths, topdir and its parent directory from the paths
> >to config files in configvars view.
>
> This works for me. Thanks!
>
> Belén
>
> >
> >[YOCTO #7463]
> >
> >Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
> >---
> > .../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 @@
> >         <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:1
> >53}}</a></td>
> >         <td class="file"><a data-toggle="modal"
> >href="#variable-{{variable.pk}}">
> >-            {% 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}}<p>
> >+                {% endfor %}
> >+            {% endif %}
> >         </a></td>
> >         <td class="description">
> >             {% if variable.description %}
> >@@ -115,7 +117,7 @@
> >                 <tbody>
> >                     {% for vh in variable.vhistory.all %}
> >                     <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>
> >                     {%endfor%}
> >                 </tbody>
> >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 <p> 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 + "<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
> >-
> >+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=bui
> >ld_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_lo
> >g_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
> >
> >--
> >_______________________________________________
> >toaster mailing list
> >toaster@yoctoproject.org
> >https://lists.yoctoproject.org/listinfo/toaster
>
> --
> _______________________________________________
> toaster mailing list
> toaster@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>



-- 
Alex Damian
Yocto Project
SSG / OTC

[-- Attachment #2: Type: text/html, Size: 14729 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [review-request][PATCH v6] bitbake: toastergui: show relative paths in configvars view
  2015-05-21  9:49               ` Damian, Alexandru
@ 2015-05-21 10:18                 ` Ed Bartosh
  0 siblings, 0 replies; 15+ messages in thread
From: Ed Bartosh @ 2015-05-21 10:18 UTC (permalink / raw)
  To: Damian, Alexandru; +Cc: toaster

On Thu, May 21, 2015 at 10:49:51AM +0100, Damian, Alexandru wrote:
> Taken for submission,
> 
> Can you please post new patches as branches on poky-contrib ?
> 
I started doing it as soon as I've got push rights to poky-contrib.

BTW, this patch is in ed/toaster/relative-path and I submitted this branch for review 3 days ago:
https://lists.yoctoproject.org/pipermail/toaster/2015-May/002159.html

Regards,
Ed

> Thank you,
> Alex
> 
> On Mon, May 18, 2015 at 1:41 PM, Barros Pena, Belen <
> belen.barros.pena@intel.com> wrote:
> 
> > On 18/05/2015 10:03, "Ed Bartosh" <ed.bartosh@linux.intel.com> wrote:
> >
> > >Reworked filtering of config paths.
> > >
> > >Stripped clone paths, topdir and its parent directory from the paths
> > >to config files in configvars view.
> >
> > This works for me. Thanks!
> >
> > Belén
> >
> > >
> > >[YOCTO #7463]
> > >
> > >Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
> > >---
> > > .../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 @@
> > >         <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:1
> > >53}}</a></td>
> > >         <td class="file"><a data-toggle="modal"
> > >href="#variable-{{variable.pk}}">
> > >-            {% 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}}<p>
> > >+                {% endfor %}
> > >+            {% endif %}
> > >         </a></td>
> > >         <td class="description">
> > >             {% if variable.description %}
> > >@@ -115,7 +117,7 @@
> > >                 <tbody>
> > >                     {% for vh in variable.vhistory.all %}
> > >                     <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>
> > >                     {%endfor%}
> > >                 </tbody>
> > >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 <p> 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 + "<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
> > >-
> > >+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=bui
> > >ld_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_lo
> > >g_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
> > >
> > >--
> > >_______________________________________________
> > >toaster mailing list
> > >toaster@yoctoproject.org
> > >https://lists.yoctoproject.org/listinfo/toaster
> >
> > --
> > _______________________________________________
> > toaster mailing list
> > toaster@yoctoproject.org
> > https://lists.yoctoproject.org/listinfo/toaster
> >
> 
> 
> 
> -- 
> Alex Damian
> Yocto Project
> SSG / OTC

-- 
--
Regards,
Ed


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-05-21 12:12 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-02 10:37 [review-request][PATCH] bitbake: toastergui: show relative paths in configvars view Ed Bartosh
2015-05-05 10:08 ` Barros Pena, Belen
2015-05-05 12:57   ` [PATCH] " Ed Bartosh
2015-05-05 14:35     ` Ed Bartosh
2015-05-05 12:59   ` [review-request][PATCH] " Ed Bartosh
2015-05-06 18:03     ` Barros Pena, Belen
2015-05-06 21:00       ` [review-request][PATCH v3] " Ed Bartosh
2015-05-06 21:03       ` [review-request][PATCH v4] " Ed Bartosh
2015-05-07  9:26         ` Damian, Alexandru
2015-05-07  9:54         ` Barros Pena, Belen
2015-05-18  8:48           ` [review-request][PATCH v5] " Ed Bartosh
2015-05-18  9:03           ` [review-request][PATCH v6] " Ed Bartosh
2015-05-18 12:41             ` Barros Pena, Belen
2015-05-21  9:49               ` Damian, Alexandru
2015-05-21 10:18                 ` Ed Bartosh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.