Hob fixes
cover Hob fixes
One of these patches is to fix a bug by removing the top empty spacing in the image combo on the image configuration screen.
The others are minor cleanup and code correction by code review.
The following changes since commit 8691a588267472eb5a32b978a0eb9ddfd0c91733:
cross-canadian.bbclass: fix rpath for sdk executables (2012-03-31 18:00:59 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib shane/hob-fixes-1
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=shane/hob-fixes-1
Shane Wang (6):
Hob: handle exceptions in get_parameters() from the bitbake
Hob: handle exceptions when loading templates
Hob: unify _size_to_string() and _string_to_size()
Hob: avoid the empty white space appearing on top of the gtk.ComboBox
Hob: a minor fix on image_fstypes
Hob: a minor fix on pmake
bitbake/lib/bb/ui/crumbs/builder.py | 26 ++++++++++---- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 35 ++++++++++++++---- bitbake/lib/bb/ui/crumbs/hoblistmodel.py | 18 +++------ bitbake/lib/bb/ui/crumbs/hobpages.py | 39 ++++++++++++++++++++ bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py | 2 + bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 11 +----- bitbake/lib/bb/ui/crumbs/packageselectionpage.py | 21 +++-------- 7 files changed, 99 insertions(+), 53 deletions(-)
Signature · 1 line
1.7.6
PATCH 1/6 Hob: handle exceptions in get_parameters() from the bitbake
Handle exceptions during type conversion into integers.
--- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 33 +++++++++++++++++++++----- 1 files changed, 26 insertions(+), 7 deletions(-)
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +26 -7
@@ -401,15 +401,22 @@ class HobHandler(gobject.GObject): num_threads = 1 max_threads = 65536 else: - num_threads = int(num_threads) - max_threads = 16 * num_threads + try: + num_threads = int(num_threads) + max_threads = 16 * num_threads + except: + num_threads = 1 + max_threads = 65536 params["max_threads"] = max_threads bbthread = self.server.runCommand(["getVariable", "BB_NUMBER_THREADS"]) if not bbthread: bbthread = num_threads else: - bbthread = int(bbthread) + try: + bbthread = int(bbthread) + except: + bbthread = num_threads params["bbthread"] = bbthread pmake = self.server.runCommand(["getVariable", "PARALLEL_MAKE"])
@@ -418,7 +425,10 @@ class HobHandler(gobject.GObject): elif isinstance(pmake, int): pass else: - pmake = int(pmake.lstrip("-j ")) + try: + pmake = int(pmake.lstrip("-j ")) + except: + pmake = num_threads params["pmake"] = pmake params["image_addr"] = self.server.runCommand(["getVariable", "DEPLOY_DIR_IMAGE"]) or ""
@@ -427,21 +437,30 @@ class HobHandler(gobject.GObject): if not image_extra_size: image_extra_size = 0 else: - image_extra_size = int(image_extra_size) + try: + image_extra_size = int(image_extra_size) + except: + image_extra_size = 0 params["image_extra_size"] = image_extra_size image_rootfs_size = self.server.runCommand(["getVariable", "IMAGE_ROOTFS_SIZE"]) if not image_rootfs_size: image_rootfs_size = 0 else: - image_rootfs_size = int(image_rootfs_size) + try: + image_rootfs_size = int(image_rootfs_size) + except: + image_rootfs_size = 0 params["image_rootfs_size"] = image_rootfs_size image_overhead_factor = self.server.runCommand(["getVariable", "IMAGE_OVERHEAD_FACTOR"]) if not image_overhead_factor: image_overhead_factor = 1 else: - image_overhead_factor = float(image_overhead_factor) + try: + image_overhead_factor = float(image_overhead_factor) + except: + image_overhead_factor = 1 params['image_overhead_factor'] = image_overhead_factor params["incompat_license"] = self.server.runCommand(["getVariable", "INCOMPATIBLE_LICENSE"]) or ""
Signature · 1 line
1.7.6
PATCH 2/6 Hob: handle exceptions when loading templates
Handle exceptions during type conversion to integers.
--- bitbake/lib/bb/ui/crumbs/builder.py | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-)
bitbake/lib/bb/ui/crumbs/builder.py +16 -4
@@ -104,10 +104,22 @@ class Configuration: self.dldir = template.getVar("DL_DIR") self.sstatedir = template.getVar("SSTATE_DIR") self.sstatemirror = template.getVar("SSTATE_MIRROR") - self.pmake = int(template.getVar("PARALLEL_MAKE").split()[1]) - self.bbthread = int(template.getVar("BB_NUMBER_THREADS")) - self.image_rootfs_size = int(template.getVar("IMAGE_ROOTFS_SIZE")) - self.image_extra_size = int(template.getVar("IMAGE_EXTRA_SPACE")) + try: + self.pmake = int(template.getVar("PARALLEL_MAKE").split()[1]) + except: + pass + try: + self.bbthread = int(template.getVar("BB_NUMBER_THREADS")) + except: + pass + try: + self.image_rootfs_size = int(template.getVar("IMAGE_ROOTFS_SIZE")) + except: + pass + try: + self.image_extra_size = int(template.getVar("IMAGE_EXTRA_SPACE")) + except: + pass # image_overhead_factor is read-only. self.incompat_license = template.getVar("INCOMPATIBLE_LICENSE") self.curr_sdk_machine = template.getVar("SDKMACHINE")
Signature · 1 line
1.7.6
PATCH 3/6 Hob: unify _size_to_string() and _string_to_size()
In reply to Shane WangWe call intsize_to_string (and string_to_intsize) in 3 different places. We unify the implementations into one place.
--- bitbake/lib/bb/ui/crumbs/hoblistmodel.py | 18 +++------- bitbake/lib/bb/ui/crumbs/hobpages.py | 39 ++++++++++++++++++++++ bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 11 +----- bitbake/lib/bb/ui/crumbs/packageselectionpage.py | 21 +++--------- 4 files changed, 51 insertions(+), 38 deletions(-)
bitbake/lib/bb/ui/crumbs/hoblistmodel.py +6 -12
@@ -22,6 +22,7 @@ import gtk import gobject +from bb.ui.crumbs.hobpages import HobPage # # PackageListModel
@@ -175,10 +176,8 @@ class PackageListModel(gtk.TreeStore): if pkgsize == "0" and not allow_empty: continue - if len(pkgsize) > 3: - size = '%.1f' % (int(pkgsize)*1.0/1024) + ' MB' - else: - size = pkgsize + ' KB' + # pkgsize is in KB + size = HobPage._size_to_string(HobPage._string_to_size(pkgsize + ' KB')) it = self.append(pniter) self.pkg_path[pkg] = self.get_path(it)
@@ -358,7 +357,7 @@ class PackageListModel(gtk.TreeStore): return packagelist """ - Return the selected package size, unit is KB. + Return the selected package size, unit is B. """ def get_packages_size(self): packages_size = 0
@@ -371,16 +370,11 @@ class PackageListModel(gtk.TreeStore): if not str_size: continue - unit = str_size.split() - if unit[1] == 'MB': - size = float(unit[0])*1024 - else: - size = float(unit[0]) - packages_size += size + packages_size += HobPage._string_to_size(str_size) child_it = self.iter_next(child_it) it = self.iter_next(it) - return "%f" % packages_size + return packages_size """ Empty self.contents by setting the include of each entry to None
bitbake/lib/bb/ui/crumbs/hobpages.py +39 -0
@@ -83,3 +83,42 @@ class HobPage (gtk.VBox): tip_text = tip button = toolbar.append_item(buttonname, tip, None, icon, cb) return button + + @staticmethod + def _size_to_string(size): + try: + if not size: + size_str = "0 B" + else: + if len(str(int(size))) > 6: + size_str = '%.1f' % (size*1.0/(1024*1024)) + ' MB' + elif len(str(int(size))) > 3: + size_str = '%.1f' % (size*1.0/1024) + ' KB' + else: + size_str = str(size) + ' B' + except: + size_str = "0 B" + return size_str + + @staticmethod + def _string_to_size(str_size): + try: + if not str_size: + size = 0 + else: + unit = str_size.split() + if len(unit) > 1: + if unit[1] == 'MB': + size = float(unit[0])*1024*1024 + elif unit[1] == 'KB': + size = float(unit[0])*1024 + elif unit[1] == 'B': + size = float(unit[0]) + else: + size = 0 + else: + size = float(unit[0]) + except: + size = 0 + return size +
bitbake/lib/bb/ui/crumbs/imagedetailspage.py +1 -10
@@ -151,15 +151,6 @@ class ImageDetailsPage (HobPage): for child in children: self.box_group_area.remove(child) - def _size_to_string(self, size): - if len(str(int(size))) > 6: - size_str = '%.1f' % (size*1.0/(1024*1024)) + ' MB' - elif len(str(int(size))) > 3: - size_str = '%.1f' % (size*1.0/1024) + ' KB' - else: - size_str = str(size) + ' B' - return size_str - def show_page(self, step): build_succeeded = (step == self.builder.IMAGE_GENERATED) image_addr = self.builder.parameters.image_addr
@@ -200,7 +191,7 @@ class ImageDetailsPage (HobPage): default_toggled = False default_image_size = 0 for image_name in image_names: - image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) + image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) if not default_toggled: default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \ or self.test_deployable(image_name)
bitbake/lib/bb/ui/crumbs/packageselectionpage.py +5 -16
@@ -161,31 +161,20 @@ class PackageSelectionPage (HobPage): self.builder.configuration.selected_packages = self.package_model.get_selected_packages() selected_packages_num = len(self.builder.configuration.selected_packages) - selected_packages_size = float(self.package_model.get_packages_size()) - selected_packages_size_str = self._size_to_string(selected_packages_size) + selected_packages_size = self.package_model.get_packages_size() + selected_packages_size_str = HobPage._size_to_string(selected_packages_size) image_overhead_factor = self.builder.configuration.image_overhead_factor - image_rootfs_size = self.builder.configuration.image_rootfs_size - image_extra_size = self.builder.configuration.image_extra_size + image_rootfs_size = self.builder.configuration.image_rootfs_size * 1024 # image_rootfs_size is KB + image_extra_size = self.builder.configuration.image_extra_size * 1024 # image_extra_size is KB base_size = image_overhead_factor * selected_packages_size image_total_size = max(base_size, image_rootfs_size) + image_extra_size - image_total_size_str = self._size_to_string(image_total_size) + image_total_size_str = HobPage._size_to_string(image_total_size) self.label.set_text("Packages included: %s\nSelected packages size: %s\nTotal image size: %s" % (selected_packages_num, selected_packages_size_str, image_total_size_str)) self.ins.show_indicator_icon("Included", selected_packages_num) - """ - Helper function to convert the package size to string format. - The unit of size is KB - """ - def _size_to_string(self, size): - if len(str(int(size))) > 3: - size_str = '%.1f' % (size*1.0/1024) + ' MB' - else: - size_str = str(size) + ' KB' - return size_str - def toggle_item_idle_cb(self, path): if not self.package_model.path_included(path): self.package_model.include_item(item_path=path, binb="User Selected")
Signature · 1 line
1.7.6
PATCH 4/6 Hob: avoid the empty white space appearing on top of the gtk.ComboBox
In reply to Shane WangAvoid the empty white space appearing on top of the machine selection combo box and the image selection combo box in the "Image configuration" screen
[Yocto #2166]
--- bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py +2 -0
@@ -143,6 +143,7 @@ class ImageConfigurationPage (HobPage): self.machine_title_desc.set_markup(mark) self.machine_combo = gtk.combo_box_new_text() + self.machine_combo.set_wrap_width(1) self.machine_combo.connect("changed", self.machine_combo_changed_cb) icon_file = hic.ICON_LAYERS_DISPLAY_FILE
@@ -191,6 +192,7 @@ class ImageConfigurationPage (HobPage): self.image_title_desc.set_markup(mark) self.image_combo = gtk.combo_box_new_text() + self.image_combo.set_wrap_width(1) self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb) self.image_desc = gtk.Label()
Signature · 1 line
1.7.6
PATCH 6/6 Hob: a minor fix on pmake
In reply to Shane Wangparams["pmake"] should be in the format "-j int".
When loading/saving "PARALLEL_MAKE" into templates, configuration.pmake will be converted into "-j int", as "PACKAGE_CLASSES" and "BBLAYERS" do.
For "PACKAGE_CLASSES" and "BBLAYERS", params["pclass"] and params["layer"] are also strings rather than the types of configuration.curr_package_format and configuration.layers.
--- bitbake/lib/bb/ui/crumbs/builder.py | 4 ++-- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
bitbake/lib/bb/ui/crumbs/builder.py +2 -2
@@ -48,7 +48,7 @@ class Configuration: self.dldir = params["dldir"] self.sstatedir = params["sstatedir"] self.sstatemirror = params["sstatemirror"] - self.pmake = params["pmake"] + self.pmake = int(params["pmake"].split()[1]) self.bbthread = params["bbthread"] self.curr_package_format = " ".join(params["pclass"].split("package_")).strip() self.image_rootfs_size = params["image_rootfs_size"]
@@ -83,7 +83,7 @@ class Configuration: self.dldir = params["dldir"] self.sstatedir = params["sstatedir"] self.sstatemirror = params["sstatemirror"] - self.pmake = params["pmake"] + self.pmake = int(params["pmake"].split()[1]) self.bbthread = params["bbthread"] self.curr_package_format = " ".join(params["pclass"].split("package_")).strip() self.image_rootfs_size = params["image_rootfs_size"]
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +1 -1
@@ -429,7 +429,7 @@ class HobHandler(gobject.GObject): pmake = int(pmake.lstrip("-j ")) except: pmake = num_threads - params["pmake"] = pmake + params["pmake"] = "-j %s" % pmake params["image_addr"] = self.server.runCommand(["getVariable", "DEPLOY_DIR_IMAGE"]) or ""
Signature · 1 line
1.7.6
PATCH 5/6 Hob: a minor fix on image_fstypes
In reply to Shane Wangimage_fstypes in the configuration has been changed into a string rather than a list. Here we correct it in __init__() of class Configuration. At other places, image_fstypes are all strings.
--- bitbake/lib/bb/ui/crumbs/builder.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
bitbake/lib/bb/ui/crumbs/builder.py +1 -1
@@ -60,7 +60,7 @@ class Configuration: self.lconf_version = params["lconf_version"] self.extra_setting = {} self.toolchain_build = False - self.image_fstypes = params["image_fstypes"].split() + self.image_fstypes = params["image_fstypes"] # bblayers.conf self.layers = params["layer"].split() # image/recipes/packages
Signature · 1 line
1.7.6