Skip to contentSkip to conversation

toaster: show suffix for image files and basename for artifact files

PATCH In review Elliot Smith 2 participants 3 messages Feb 2, 2016 – Feb 23, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: show suffix for image files and basename for artifact files

The build dashboard doesn't show image and artifact files correctly, as it shows the full filename for images and the filename plus path relative to DEPLOY_DIR for artifacts.

Instead, show just the suffix for image files, and the basename for artifact files.

---
 bitbake/lib/toaster/orm/models.py                  |  8 ++++++++
 .../toastergui/templates/builddashboard.html       | 22 +++++++++++-----------
 bitbake/lib/toaster/toastergui/views.py            |  7 ++++++-
 3 files changed, 25 insertions(+), 12 deletions(-)
bitbake/lib/toaster/orm/models.py +8 -0
index ac2aa9e..bb95b75 100644
@@ -522,6 +522,8 @@ class BuildArtifact(models.Model):
 
         return self.file_name
 
+    def get_basename(self):
+        return os.path.basename(self.file_name)
 
     def is_available(self):
         return self.build.buildrequest.environment.has_artifact(self.file_name)
@@ -560,6 +562,12 @@ class Target_Image_File(models.Model):
     file_name = models.FilePathField(max_length=254)
     file_size = models.IntegerField()
 
+    @property
+    def suffix(self):
+        filename, suffix = os.path.splitext(self.file_name)
+        suffix = suffix.lstrip('.')
+        return suffix
+
 class Target_File(models.Model):
     ITYPE_REGULAR = 1
     ITYPE_DIRECTORY = 2
bitbake/lib/toaster/toastergui/templates/builddashboard.html +11 -11
index 323bbbb..5dac4db 100644
@@ -111,7 +111,7 @@
                                   </p>
                     </div>
                 </div>
-                        {% else %}
+        {% else %}
             <dt>
                 <i class="icon-question-sign get-help" title="The location in disk of the license manifest, a document listing all packages installed in your image and their licenses"></i>
 
@@ -126,18 +126,18 @@
             </dt>
             <dd>
                 <ul>
-                                  {% for i in target.imageFiles %}
-            {% if build.project %}
-                    <li><a href="{% url 'build_artifact' build.pk 'imagefile' i.id %}">{{i.path}}</a>
-            {% else %}
-                    <li>{{i.path}}
-            {% endif %}
-                    ({{i.size|filtered_filesizeformat}})</li>
-                                  {% endfor %}
+                    {% for i in target.imageFiles %}
+                        <li>
+                            <a href="{% url 'build_artifact' build.pk 'imagefile' i.id %}">
+                                {{i.suffix}}
+                            </a>
+                            &nbsp;({{i.size|filtered_filesizeformat}})
+                        </li>
+                    {% endfor %}
                 </ul>
             </dd>
         </dl>
-                        {% endif %}
+        {% endif %}
     </div>
         {% endif %}
     {% endfor %}
@@ -161,7 +161,7 @@
             <dd><div>
               {% for ba in build.buildartifact_set.all|dictsort:"file_name" %}
                 <a href="{%url 'build_artifact' build.id 'buildartifact' ba.id %}">
-                    {{ba.get_local_file_name}}
+                    {{ba.get_basename}}
                 </a>
 
                 ({{ba.file_size|filtered_filesizeformat}}) <br/>
bitbake/lib/toaster/toastergui/views.py +6 -1
index 995937a..4932885 100755
@@ -480,7 +480,12 @@ def builddashboard( request, build_id ):
             if ( ndx < 0 ):
                 ndx = 0;
             f = i.file_name[ ndx + 1: ]
-            imageFiles.append({ 'id': i.id, 'path': f, 'size' : i.file_size })
+            imageFiles.append({
+                'id': i.id,
+                'path': f,
+                'size': i.file_size,
+                'suffix': i.suffix
+            })
         if t.is_image and (len(imageFiles) <= 0 or len(t.license_manifest_path) <= 0):
             targetHasNoImages = True
         elem[ 'imageFiles' ] = imageFiles
Signature · 14 lines
Elliot Smith
Software Engineer
Intel OTC

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#1 lore raw
Quoted 4 lines · Elliot Smith

The build dashboard doesn't show image and artifact files correctly, as it shows the full filename for images and the filename plus path relative to DEPLOY_DIR for artifacts.

Note that Belen has already informally reviewed this patch and verified its behaviour:
https://lists.yoctoproject.org/pipermail/toaster/2016-February/003760.html

Elliot

Quoted 135 lines

Instead, show just the suffix for image files, and the basename for artifact files.

---
 bitbake/lib/toaster/orm/models.py                  |  8 ++++++++
 .../toastergui/templates/builddashboard.html       | 22
+++++++++++-----------
 bitbake/lib/toaster/toastergui/views.py            |  7 ++++++-
 3 files changed, 25 insertions(+), 12 deletions(-)
bitbake/lib/toaster/orm/models.py +2 -0
index ac2aa9e..bb95b75 100644
@@ -522,6 +522,8 @@ class BuildArtifact(models.Model):
 
         return self.file_name
 
+    def get_basename(self):
+        return os.path.basename(self.file_name)
 
     def is_available(self):
         return

self.build.buildrequest.environment.has_artifact(self.file_name)

bitbake/lib/toaster/orm/models.py +6 -0
@@ -560,6 +562,12 @@ class Target_Image_File(models.Model):
     file_name = models.FilePathField(max_length=254)
     file_size = models.IntegerField()
 
+    @property
+    def suffix(self):
+        filename, suffix = os.path.splitext(self.file_name)
+        suffix = suffix.lstrip('.')
+        return suffix
+
 class Target_File(models.Model):
     ITYPE_REGULAR = 1
     ITYPE_DIRECTORY = 2
bitbake/lib/toaster/toastergui/templates/builddashboard.html +1 -1
index 323bbbb..5dac4db 100644
@@ -111,7 +111,7 @@
                                   </p>
                     </div>
                 </div>
-                        {% else %}
+        {% else %}
             <dt>
                 <i class="icon-question-sign get-help" title="The

location in disk of the license manifest, a document listing all packages installed in your image and their licenses"></i>

bitbake/lib/toaster/toastergui/templates/builddashboard.html +0 -3
@@ -126,18 +126,18 @@
             </dt>
             <dd>
                 <ul>
-                                  {% for i in target.imageFiles %}
-            {% if build.project %}
-                    <li><a href="{% url 'build_artifact' build.pk

'imagefile' i.id %}">{{i.path}}</a>

bitbake/lib/toaster/toastergui/templates/builddashboard.html +3 -5
-            {% else %}
-                    <li>{{i.path}}
-            {% endif %}
-                    ({{i.size|filtered_filesizeformat}})</li>
-                                  {% endfor %}
+                    {% for i in target.imageFiles %}
+                        <li>
+                            <a href="{% url 'build_artifact' build.pk

'imagefile' i.id %}">

bitbake/lib/toaster/toastergui/templates/builddashboard.html +6 -1
+                                {{i.suffix}}
+                            </a>
+                            &nbsp;({{i.size|filtered_filesizeformat}})
+                        </li>
+                    {% endfor %}
                 </ul>
             </dd>
         </dl>
-                        {% endif %}
+        {% endif %}
     </div>
         {% endif %}
     {% endfor %}
@@ -161,7 +161,7 @@
             <dd><div>
               {% for ba in
 build.buildartifact_set.all|dictsort:"file_name" %}
                 <a href="{%url 'build_artifact' build.id 'buildartifact'

ba.id %}">

bitbake/lib/toaster/toastergui/templates/builddashboard.html +1 -1
-                    {{ba.get_local_file_name}}
+                    {{ba.get_basename}}
                 </a>
 
                 ({{ba.file_size|filtered_filesizeformat}}) <br/>
bitbake/lib/toaster/toastergui/views.py +6 -1
index 995937a..4932885 100755
@@ -480,7 +480,12 @@ def builddashboard( request, build_id ):
             if ( ndx < 0 ):
                 ndx = 0;
             f = i.file_name[ ndx + 1: ]
-            imageFiles.append({ 'id': i.id, 'path': f, 'size' :
 i.file_size })
+            imageFiles.append({
+                'id': i.id,
+                'path': f,
+                'size': i.file_size,
+                'suffix': i.suffix
+            })
         if t.is_image and (len(imageFiles) <= 0 or

len(t.license_manifest_path) <= 0):
targetHasNoImages = True
elem[ 'imageFiles' ] = imageFiles
--
Elliot Smith
Software Engineer
Intel OTC

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
#2 lore raw

Thanks sent to bitbake-devel and pushed to toaster-next

Quoted 157 lines · Elliot

On 2 February 2016 at 10:11, Elliot Smith <[email protected] <mailto:[email protected]>> wrote:

The build dashboard doesn't show image and artifact files correctly, as it shows the full filename for images and the filename plus path relative to DEPLOY_DIR for artifacts.

Note that Belen has already informally reviewed this patch and verified its behaviour:
https://lists.yoctoproject.org/pipermail/toaster/2016-February/003760.html

Elliot

Instead, show just the suffix for image files, and the basename for artifact files.

<mailto:[email protected]>>
---
bitbake/lib/toaster/orm/models.py | 8 ++++++++
.../toastergui/templates/builddashboard.html | 22
+++++++++++-----------
bitbake/lib/toaster/toastergui/views.py | 7 ++++++-
3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index ac2aa9e..bb95b75 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -522,6 +522,8 @@ class BuildArtifact(models.Model):

return self.file_name

+ def get_basename(self):
+ return os.path.basename(self.file_name)

def is_available(self):
return
self.build.buildrequest.environment.has_artifact(self.file_name) @@ -560,6 +562,12 @@ class Target_Image_File(models.Model):
file_name = models.FilePathField(max_length=254) file_size = models.IntegerField()

+ @property
+ def suffix(self):
+ filename, suffix = os.path.splitext(self.file_name)
+ suffix = suffix.lstrip('.')
+ return suffix
+
class Target_File(models.Model):
ITYPE_REGULAR = 1
ITYPE_DIRECTORY = 2
diff --git a/bitbake/lib/toaster/toastergui/templates/builddashboard.html b/bitbake/lib/toaster/toastergui/templates/builddashboard.html index 323bbbb..5dac4db 100644
--- a/bitbake/lib/toaster/toastergui/templates/builddashboard.html +++ b/bitbake/lib/toaster/toastergui/templates/builddashboard.html @@ -111,7 +111,7 @@
</p>
</div>
</div>
- {% else %}
+ {% else %}
<dt>
<i class="icon-question-sign get-help" title="The
location in disk of the license manifest, a document listing all packages installed in your image and their licenses"></i>

@@ -126,18 +126,18 @@
</dt>
<dd>
<ul>
- {% for i in target.imageFiles %}
- {% if build.project %}
- <li><a href="{% url 'build_artifact' build.pk
<http://build.pk> 'imagefile' i.id <http://i.id> %}">{{i.path}}</a>
- {% else %}
- <li>{{i.path}}
- {% endif %}
- ({{i.size|filtered_filesizeformat}})</li>
- {% endfor %}
+ {% for i in target.imageFiles %}
+ <li>
+ <a href="{% url 'build_artifact'
build.pk <http://build.pk> 'imagefile' i.id <http://i.id> %}">
+ {{i.suffix}}
+ </a>
+ &nbsp;({{i.size|filtered_filesizeformat}})
+ </li>
+ {% endfor %}
</ul>
</dd>
</dl>
- {% endif %}
+ {% endif %}
</div>
{% endif %}
{% endfor %}
@@ -161,7 +161,7 @@
<dd><div>
{% for ba in
build.buildartifact_set.all|dictsort:"file_name" %}
<a href="{%url 'build_artifact' build.id
<http://build.id> 'buildartifact' ba.id <http://ba.id> %}">
- {{ba.get_local_file_name}}
+ {{ba.get_basename}}
</a>

({{ba.file_size|filtered_filesizeformat}}) <br/>
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 995937a..4932885 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -480,7 +480,12 @@ def builddashboard( request, build_id ):
if ( ndx < 0 ):
ndx = 0;
f = i.file_name[ ndx + 1: ]
- imageFiles.append({ 'id': i.id <http://i.id>, 'path':
f, 'size' : i.file_size })
+ imageFiles.append({
+ 'id': i.id <http://i.id>,
+ 'path': f,
+ 'size': i.file_size,
+ 'suffix': i.suffix
+ })
if t.is_image and (len(imageFiles) <= 0 or
len(t.license_manifest_path) <= 0):
targetHasNoImages = True
elem[ 'imageFiles' ] = imageFiles
--
Elliot Smith
Software Engineer
Intel OTC

---------------------------------------------------------------------
Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre