[bitbake-devel] [PATCH 13/14] toaster: correct package count

Alex DAMIAN alexandru.damian at intel.com
Fri Apr 4 14:10:52 UTC 2014


From: Farrell Wymore <farrell.wymore at windriver.com>

The package count was incorrect because it was counting anonymous
packages. the full path of the image files was shortened to just
the filename.

[YOCTO 6087]
[YOCTO 6091]

Signed-off-by: Farrell Wymore <farrell.wymore at windriver.com>
---
 .../toastergui/templates/builddashboard.html       |  2 +-
 lib/toaster/toastergui/views.py                    | 73 ++++++++++++++--------
 2 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/lib/toaster/toastergui/templates/builddashboard.html b/lib/toaster/toastergui/templates/builddashboard.html
index 891d860..fa4b194 100644
--- a/lib/toaster/toastergui/templates/builddashboard.html
+++ b/lib/toaster/toastergui/templates/builddashboard.html
@@ -155,7 +155,7 @@
         <h4><a href="{% url 'recipes' build.pk %}">Recipes</a> & <a href="{% url 'packages' build.pk %}">Packages</a></h4>
             <dl>
         <dt>Recipes built</dt><dd><a href="{% url 'recipes' build.pk %}">{{recipecount}}</a></dd>
-        <dt>Packages built</dt><dd><a href="{% url 'packages' build.pk %}">{{build.package_set.all.count}}</a></dd>
+        <dt>Packages built</dt><dd><a href="{% url 'packages' build.pk %}">{{packagecount}}</a></dd>
             </dl>
     </div>
 </div>
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index e346ac4..2da81c1 100644
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -381,42 +381,60 @@ def builds(request):
 # Each build may contain multiple targets and each target
 # may generate multiple image files. display them all.
 #
-def builddashboard(request, build_id):
+def builddashboard( request, build_id ):
     template = "builddashboard.html"
-    if Build.objects.filter(pk=build_id).count() == 0 :
-        return redirect(builds)
-    build = Build.objects.filter(pk = build_id)[0];
+    if Build.objects.filter( pk=build_id ).count( ) == 0 :
+        return redirect( builds )
+    build = Build.objects.filter( pk = build_id )[ 0 ];
     layerVersionId = Layer_Version.objects.filter( build = build_id );
     recipeCount = Recipe.objects.filter( layer_version__id__in = layerVersionId ).count( );
     tgts = Target.objects.filter( build_id = build_id ).order_by( 'target' );
 
+    ##
     # set up custom target list with computed package and image data
-    targets = [ ];
-    ntargets = 0;
-    hasImages = False;
+    #
+
+    targets = [ ]
+    ntargets = 0
+    hasImages = False
     for t in tgts:
-        elem = { };
-        elem[ 'target' ] = t;
+        elem = { }
+        elem[ 'target' ] = t
         if ( t.is_image ):
-            hasImages = True;
-        npkg = 0;
-        pkgsz = 0;
-        pid= 0;
-        tp = Target_Installed_Package.objects.filter( target_id = t.id );
-        package = None;
+            hasImages = True
+        npkg = 0
+        pkgsz = 0
+        pid= 0
+        tp = Target_Installed_Package.objects.filter( target_id = t.id )
+        package = None
         for p in tp:
-            pid = p.package_id;
+            pid = p.package_id
             package = Package.objects.get( pk = p.package_id )
-            pkgsz = pkgsz + package.size;
-            npkg = npkg + 1;
-        elem[ 'npkg' ] = npkg;
-        elem[ 'pkgsz' ] = pkgsz;
-        ti = Target_Image_File.objects.filter( target_id = t.id );
-        imageFiles = [ ];
+            pkgsz = pkgsz + package.size
+            if ( package.installed_name ):
+                npkg = npkg + 1
+        elem[ 'npkg' ] = npkg
+        elem[ 'pkgsz' ] = pkgsz
+        ti = Target_Image_File.objects.filter( target_id = t.id )
+        imageFiles = [ ]
         for i in ti:
-            imageFiles.append({ 'path': i.file_name, 'size' : i.file_size });
-        elem[ 'imageFiles' ] = imageFiles;
-        targets.append( elem );
+            ndx = i.file_name.rfind( '/' )
+            if ( ndx < 0 ):
+                ndx = 0;
+            f = i.file_name[ ndx + 1: ]
+            imageFiles.append({ 'path': f, 'size' : i.file_size })
+        elem[ 'imageFiles' ] = imageFiles
+        targets.append( elem )
+
+    ##
+    # how many packages in this build - ignore anonymous ones
+    #
+
+    packageCount = 0
+    packages = Package.objects.filter( build_id = build_id )
+    for p in packages:
+        if ( p.installed_name ):
+            packageCount = packageCount + 1
 
     context = {
             'build'           : build,
@@ -424,9 +442,10 @@ def builddashboard(request, build_id):
             'ntargets'        : ntargets,
             'targets'         : targets,
             'recipecount'     : recipeCount,
-            'logmessages'     : LogMessage.objects.filter(build=build_id),
+            'packagecount'    : packageCount,
+            'logmessages'     : LogMessage.objects.filter( build = build_id ),
     }
-    return render(request, template, context)
+    return render( request, template, context )
 
 
 def task(request, build_id, task_id):
-- 
1.9.1




More information about the bitbake-devel mailing list