summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/ui/crumbs/hoblistmodel.py18
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/hobpages.py39
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/imagedetailspage.py11
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/packageselectionpage.py21
4 files changed, 51 insertions, 38 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
index 5dddffa327..4934ba8ed8 100644
--- a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
+++ b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
@@ -22,6 +22,7 @@
22 22
23import gtk 23import gtk
24import gobject 24import gobject
25from bb.ui.crumbs.hobpages import HobPage
25 26
26# 27#
27# PackageListModel 28# PackageListModel
@@ -175,10 +176,8 @@ class PackageListModel(gtk.TreeStore):
175 if pkgsize == "0" and not allow_empty: 176 if pkgsize == "0" and not allow_empty:
176 continue 177 continue
177 178
178 if len(pkgsize) > 3: 179 # pkgsize is in KB
179 size = '%.1f' % (int(pkgsize)*1.0/1024) + ' MB' 180 size = HobPage._size_to_string(HobPage._string_to_size(pkgsize + ' KB'))
180 else:
181 size = pkgsize + ' KB'
182 181
183 it = self.append(pniter) 182 it = self.append(pniter)
184 self.pkg_path[pkg] = self.get_path(it) 183 self.pkg_path[pkg] = self.get_path(it)
@@ -391,7 +390,7 @@ class PackageListModel(gtk.TreeStore):
391 390
392 return packagelist 391 return packagelist
393 """ 392 """
394 Return the selected package size, unit is KB. 393 Return the selected package size, unit is B.
395 """ 394 """
396 def get_packages_size(self): 395 def get_packages_size(self):
397 packages_size = 0 396 packages_size = 0
@@ -404,16 +403,11 @@ class PackageListModel(gtk.TreeStore):
404 if not str_size: 403 if not str_size:
405 continue 404 continue
406 405
407 unit = str_size.split() 406 packages_size += HobPage._string_to_size(str_size)
408 if unit[1] == 'MB':
409 size = float(unit[0])*1024
410 else:
411 size = float(unit[0])
412 packages_size += size
413 407
414 child_it = self.iter_next(child_it) 408 child_it = self.iter_next(child_it)
415 it = self.iter_next(it) 409 it = self.iter_next(it)
416 return "%f" % packages_size 410 return packages_size
417 411
418 """ 412 """
419 Empty self.contents by setting the include of each entry to None 413 Empty self.contents by setting the include of each entry to None
diff --git a/bitbake/lib/bb/ui/crumbs/hobpages.py b/bitbake/lib/bb/ui/crumbs/hobpages.py
index d8e59c44dc..5045ea2019 100755
--- a/bitbake/lib/bb/ui/crumbs/hobpages.py
+++ b/bitbake/lib/bb/ui/crumbs/hobpages.py
@@ -83,3 +83,42 @@ class HobPage (gtk.VBox):
83 tip_text = tip 83 tip_text = tip
84 button = toolbar.append_item(buttonname, tip, None, icon, cb) 84 button = toolbar.append_item(buttonname, tip, None, icon, cb)
85 return button 85 return button
86
87 @staticmethod
88 def _size_to_string(size):
89 try:
90 if not size:
91 size_str = "0 B"
92 else:
93 if len(str(int(size))) > 6:
94 size_str = '%.1f' % (size*1.0/(1024*1024)) + ' MB'
95 elif len(str(int(size))) > 3:
96 size_str = '%.1f' % (size*1.0/1024) + ' KB'
97 else:
98 size_str = str(size) + ' B'
99 except:
100 size_str = "0 B"
101 return size_str
102
103 @staticmethod
104 def _string_to_size(str_size):
105 try:
106 if not str_size:
107 size = 0
108 else:
109 unit = str_size.split()
110 if len(unit) > 1:
111 if unit[1] == 'MB':
112 size = float(unit[0])*1024*1024
113 elif unit[1] == 'KB':
114 size = float(unit[0])*1024
115 elif unit[1] == 'B':
116 size = float(unit[0])
117 else:
118 size = 0
119 else:
120 size = float(unit[0])
121 except:
122 size = 0
123 return size
124
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index 5a6324d2a4..b685d11e69 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -151,15 +151,6 @@ class ImageDetailsPage (HobPage):
151 for child in children: 151 for child in children:
152 self.box_group_area.remove(child) 152 self.box_group_area.remove(child)
153 153
154 def _size_to_string(self, size):
155 if len(str(int(size))) > 6:
156 size_str = '%.1f' % (size*1.0/(1024*1024)) + ' MB'
157 elif len(str(int(size))) > 3:
158 size_str = '%.1f' % (size*1.0/1024) + ' KB'
159 else:
160 size_str = str(size) + ' B'
161 return size_str
162
163 def show_page(self, step): 154 def show_page(self, step):
164 build_succeeded = (step == self.builder.IMAGE_GENERATED) 155 build_succeeded = (step == self.builder.IMAGE_GENERATED)
165 image_addr = self.builder.parameters.image_addr 156 image_addr = self.builder.parameters.image_addr
@@ -200,7 +191,7 @@ class ImageDetailsPage (HobPage):
200 default_toggled = False 191 default_toggled = False
201 default_image_size = 0 192 default_image_size = 0
202 for image_name in image_names: 193 for image_name in image_names:
203 image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) 194 image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size)
204 if not default_toggled: 195 if not default_toggled:
205 default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \ 196 default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \
206 or self.test_deployable(image_name) 197 or self.test_deployable(image_name)
diff --git a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
index 9a847c0f83..7926636e07 100755
--- a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
@@ -162,31 +162,20 @@ class PackageSelectionPage (HobPage):
162 self.builder.configuration.selected_packages = self.package_model.get_selected_packages() 162 self.builder.configuration.selected_packages = self.package_model.get_selected_packages()
163 self.builder.configuration.user_selected_packages = self.package_model.get_user_selected_packages() 163 self.builder.configuration.user_selected_packages = self.package_model.get_user_selected_packages()
164 selected_packages_num = len(self.builder.configuration.selected_packages) 164 selected_packages_num = len(self.builder.configuration.selected_packages)
165 selected_packages_size = float(self.package_model.get_packages_size()) 165 selected_packages_size = self.package_model.get_packages_size()
166 selected_packages_size_str = self._size_to_string(selected_packages_size) 166 selected_packages_size_str = HobPage._size_to_string(selected_packages_size)
167 167
168 image_overhead_factor = self.builder.configuration.image_overhead_factor 168 image_overhead_factor = self.builder.configuration.image_overhead_factor
169 image_rootfs_size = self.builder.configuration.image_rootfs_size 169 image_rootfs_size = self.builder.configuration.image_rootfs_size * 1024 # image_rootfs_size is KB
170 image_extra_size = self.builder.configuration.image_extra_size 170 image_extra_size = self.builder.configuration.image_extra_size * 1024 # image_extra_size is KB
171 base_size = image_overhead_factor * selected_packages_size 171 base_size = image_overhead_factor * selected_packages_size
172 image_total_size = max(base_size, image_rootfs_size) + image_extra_size 172 image_total_size = max(base_size, image_rootfs_size) + image_extra_size
173 image_total_size_str = self._size_to_string(image_total_size) 173 image_total_size_str = HobPage._size_to_string(image_total_size)
174 174
175 self.label.set_text("Packages included: %s\nSelected packages size: %s\nTotal image size: %s" % 175 self.label.set_text("Packages included: %s\nSelected packages size: %s\nTotal image size: %s" %
176 (selected_packages_num, selected_packages_size_str, image_total_size_str)) 176 (selected_packages_num, selected_packages_size_str, image_total_size_str))
177 self.ins.show_indicator_icon("Included", selected_packages_num) 177 self.ins.show_indicator_icon("Included", selected_packages_num)
178 178
179 """
180 Helper function to convert the package size to string format.
181 The unit of size is KB
182 """
183 def _size_to_string(self, size):
184 if len(str(int(size))) > 3:
185 size_str = '%.1f' % (size*1.0/1024) + ' MB'
186 else:
187 size_str = str(size) + ' KB'
188 return size_str
189
190 def toggle_item_idle_cb(self, path): 179 def toggle_item_idle_cb(self, path):
191 if not self.package_model.path_included(path): 180 if not self.package_model.path_included(path):
192 self.package_model.include_item(item_path=path, binb="User Selected") 181 self.package_model.include_item(item_path=path, binb="User Selected")