def refresh_selection(self): self.builder.configuration.selected_packages = self.package_model.get_selected_packages( ) self.builder.configuration.user_selected_packages = self.package_model.get_user_selected_packages( ) selected_packages_num = len( self.builder.configuration.selected_packages) 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 / 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 if "zypper" in self.builder.configuration.selected_packages: image_total_size += (51200 * 1024) image_total_size_str = HobPage._size_to_string(image_total_size) self.label.set_label( "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 packages", selected_packages_num)
def populate(self, pkginfolist): self.clear() self.pkgs_size = 0 self.pn_path = {} self.pkg_path = {} self.rprov_pkg = {} def getpkgvalue(pkgdict, key, pkgname, defaultval = None): value = pkgdict.get('%s_%s' % (key, pkgname), None) if not value: value = pkgdict.get(key, defaultval) return value for pkginfo in pkginfolist: pn = pkginfo['PN'] pv = pkginfo['PV'] pr = pkginfo['PR'] if pn in self.pn_path.keys(): pniter = self.get_iter(self.pn_path[pn]) else: pniter = self.append(None) self.set(pniter, self.COL_NAME, pn + '-' + pv + '-' + pr, self.COL_INC, False) self.pn_path[pn] = self.get_path(pniter) # PKG is always present pkg = pkginfo['PKG'] pkgv = getpkgvalue(pkginfo, 'PKGV', pkg) pkgr = getpkgvalue(pkginfo, 'PKGR', pkg) # PKGSIZE is artificial, will always be overridden with the package name if present pkgsize = pkginfo.get('PKGSIZE_%s' % pkg, "0") # PKG_%s is the renamed version pkg_rename = pkginfo.get('PKG_%s' % pkg, "") # The rest may be overridden or not section = getpkgvalue(pkginfo, 'SECTION', pkg, "") summary = getpkgvalue(pkginfo, 'SUMMARY', pkg, "") rdep = getpkgvalue(pkginfo, 'RDEPENDS', pkg, "") rrec = getpkgvalue(pkginfo, 'RRECOMMENDS', pkg, "") rprov = getpkgvalue(pkginfo, 'RPROVIDES', pkg, "") for i in rprov.split(): self.rprov_pkg[i] = pkg allow_empty = getpkgvalue(pkginfo, 'ALLOW_EMPTY', pkg, "") if pkgsize == "0" and not allow_empty: continue # 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) self.set(it, self.COL_NAME, pkg, self.COL_VER, pkgv, self.COL_REV, pkgr, self.COL_RNM, pkg_rename, self.COL_SEC, section, self.COL_SUM, summary, self.COL_RDEP, rdep + ' ' + rrec, self.COL_RPROV, rprov, self.COL_SIZE, size, self.COL_BINB, "", self.COL_INC, False, self.COL_FONT, '10')
def refresh_selection(self): self.builder.configuration.selected_packages = self.package_model.get_selected_packages() self.builder.configuration.user_selected_packages = self.package_model.get_user_selected_packages() selected_packages_num = len(self.builder.configuration.selected_packages) selected_packages_size = self.package_model.get_packages_size() selected_packages_size_str = HobPage._size_to_string(selected_packages_size) self.label.set_label("Packages included: %s Selected packages size: %s" % (selected_packages_num, selected_packages_size_str))
def populate(self, pkginfolist): # First clear the model, in case repopulating self.clear() def getpkgvalue(pkgdict, key, pkgname, defaultval=None): value = pkgdict.get('%s_%s' % (key, pkgname), None) if not value: value = pkgdict.get(key, defaultval) return value for pkginfo in pkginfolist: pn = pkginfo['PN'] pv = pkginfo['PV'] pr = pkginfo['PR'] pkg = pkginfo['PKG'] pkgv = getpkgvalue(pkginfo, 'PKGV', pkg) pkgr = getpkgvalue(pkginfo, 'PKGR', pkg) # PKGSIZE is artificial, will always be overridden with the package name if present pkgsize = pkginfo.get('PKGSIZE_%s' % pkg, "0") # PKG_%s is the renamed version pkg_rename = pkginfo.get('PKG_%s' % pkg, "") # The rest may be overridden or not section = getpkgvalue(pkginfo, 'SECTION', pkg, "") summary = getpkgvalue(pkginfo, 'SUMMARY', pkg, "") rdep = getpkgvalue(pkginfo, 'RDEPENDS', pkg, "") rrec = getpkgvalue(pkginfo, 'RRECOMMENDS', pkg, "") rprov = getpkgvalue(pkginfo, 'RPROVIDES', pkg, "") files_list = getpkgvalue(pkginfo, 'FILES_INFO', pkg, "") for i in rprov.split(): self.rprov_pkg[i] = pkg recipe = pn + '-' + pv + '-' + pr allow_empty = getpkgvalue(pkginfo, 'ALLOW_EMPTY', pkg, "") if pkgsize == "0" and not allow_empty: continue # pkgsize is in KB size = HobPage._size_to_string( HobPage._string_to_size(pkgsize + ' KB')) self.set(self.append(), self.COL_NAME, pkg, self.COL_VER, pkgv, self.COL_REV, pkgr, self.COL_RNM, pkg_rename, self.COL_SEC, section, self.COL_SUM, summary, self.COL_RDEP, rdep + ' ' + rrec, self.COL_RPROV, rprov, self.COL_SIZE, size, self.COL_RCP, recipe, self.COL_BINB, "", self.COL_INC, False, self.COL_FONT, '10', self.COL_FLIST, files_list) self.pn_path = {} it = self.get_iter_first() while it: pn = self.get_value(it, self.COL_NAME) path = self.get_path(it) self.pn_path[pn] = path it = self.iter_next(it)
def populate(self, pkginfolist): # First clear the model, in case repopulating self.clear() def getpkgvalue(pkgdict, key, pkgname, defaultval = None): value = pkgdict.get('%s_%s' % (key, pkgname), None) if not value: value = pkgdict.get(key, defaultval) return value for pkginfo in pkginfolist: pn = pkginfo['PN'] pv = pkginfo['PV'] pr = pkginfo['PR'] pkg = pkginfo['PKG'] pkgv = getpkgvalue(pkginfo, 'PKGV', pkg) pkgr = getpkgvalue(pkginfo, 'PKGR', pkg) # PKGSIZE is artificial, will always be overridden with the package name if present pkgsize = pkginfo.get('PKGSIZE_%s' % pkg, "0") # PKG_%s is the renamed version pkg_rename = pkginfo.get('PKG_%s' % pkg, "") # The rest may be overridden or not section = getpkgvalue(pkginfo, 'SECTION', pkg, "") summary = getpkgvalue(pkginfo, 'SUMMARY', pkg, "") rdep = getpkgvalue(pkginfo, 'RDEPENDS', pkg, "") rrec = getpkgvalue(pkginfo, 'RRECOMMENDS', pkg, "") rprov = getpkgvalue(pkginfo, 'RPROVIDES', pkg, "") files_list = getpkgvalue(pkginfo, 'FILES_INFO', pkg, "") for i in rprov.split(): self.rprov_pkg[i] = pkg recipe = pn + '-' + pv + '-' + pr allow_empty = getpkgvalue(pkginfo, 'ALLOW_EMPTY', pkg, "") if pkgsize == "0" and not allow_empty: continue # pkgsize is in KB size = HobPage._size_to_string(HobPage._string_to_size(pkgsize + ' KB')) self.set(self.append(), self.COL_NAME, pkg, self.COL_VER, pkgv, self.COL_REV, pkgr, self.COL_RNM, pkg_rename, self.COL_SEC, section, self.COL_SUM, summary, self.COL_RDEP, rdep + ' ' + rrec, self.COL_RPROV, rprov, self.COL_SIZE, size, self.COL_RCP, recipe, self.COL_BINB, "", self.COL_INC, False, self.COL_FONT, '10', self.COL_FLIST, files_list) self.pn_path = {} it = self.get_iter_first() while it: pn = self.get_value(it, self.COL_NAME) path = self.get_path(it) self.pn_path[pn] = path it = self.iter_next(it)
def refresh_selection(self): self.builder.configuration.selected_packages = self.package_model.get_selected_packages() self.builder.configuration.user_selected_packages = self.package_model.get_user_selected_packages() selected_packages_num = len(self.builder.configuration.selected_packages) 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 / 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 if "zypper" in self.builder.configuration.selected_packages: image_total_size += (51200 * 1024) image_total_size_str = HobPage._size_to_string(image_total_size) self.label.set_label("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 packages", selected_packages_num)
def populate(self, pkginfolist): self.clear() self.pkgs_size = 0 self.pn_path = {} self.pkg_path = {} self.rprov_pkg = {} for pkginfo in pkginfolist: pn = pkginfo['PN'] pv = pkginfo['PV'] pr = pkginfo['PR'] if pn in self.pn_path.keys(): pniter = self.get_iter(self.pn_path[pn]) else: pniter = self.append(None) self.set(pniter, self.COL_NAME, pn + '-' + pv + '-' + pr, self.COL_INC, False) self.pn_path[pn] = self.get_path(pniter) pkg = pkginfo['PKG'] pkgv = pkginfo['PKGV'] pkgr = pkginfo['PKGR'] pkgsize = pkginfo['PKGSIZE_%s' % pkg] if 'PKGSIZE_%s' % pkg in pkginfo.keys() else "0" pkg_rename = pkginfo['PKG_%s' % pkg] if 'PKG_%s' % pkg in pkginfo.keys() else "" section = pkginfo['SECTION_%s' % pkg] if 'SECTION_%s' % pkg in pkginfo.keys() else "" summary = pkginfo['SUMMARY_%s' % pkg] if 'SUMMARY_%s' % pkg in pkginfo.keys() else "" rdep = pkginfo['RDEPENDS_%s' % pkg] if 'RDEPENDS_%s' % pkg in pkginfo.keys() else "" rrec = pkginfo['RRECOMMENDS_%s' % pkg] if 'RRECOMMENDS_%s' % pkg in pkginfo.keys() else "" rprov = pkginfo['RPROVIDES_%s' % pkg] if 'RPROVIDES_%s' % pkg in pkginfo.keys() else "" for i in rprov.split(): self.rprov_pkg[i] = pkg if 'ALLOW_EMPTY_%s' % pkg in pkginfo.keys(): allow_empty = pkginfo['ALLOW_EMPTY_%s' % pkg] elif 'ALLOW_EMPTY' in pkginfo.keys(): allow_empty = pkginfo['ALLOW_EMPTY'] else: allow_empty = "" if pkgsize == "0" and not allow_empty: continue # 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) self.set(it, self.COL_NAME, pkg, self.COL_VER, pkgv, self.COL_REV, pkgr, self.COL_RNM, pkg_rename, self.COL_SEC, section, self.COL_SUM, summary, self.COL_RDEP, rdep + ' ' + rrec, self.COL_RPROV, rprov, self.COL_SIZE, size, self.COL_BINB, "", self.COL_INC, False, self.COL_FONT, '10')
def refresh_selection(self): self.builder.configuration.selected_packages = self.package_model.get_selected_packages( ) self.builder.configuration.user_selected_packages = self.package_model.get_user_selected_packages( ) selected_packages_num = len( self.builder.configuration.selected_packages) selected_packages_size = self.package_model.get_packages_size() selected_packages_size_str = HobPage._size_to_string( selected_packages_size) self.label.set_label( "Packages included: %s Selected packages size: %s" % (selected_packages_num, selected_packages_size_str))
def show_page(self, step): self.build_succeeded = (step == self.builder.IMAGE_GENERATED) image_addr = self.builder.parameters.image_addr image_names = self.builder.parameters.image_names if self.build_succeeded: machine = self.builder.configuration.curr_mach base_image = self.builder.recipe_model.get_selected_image() layers = self.builder.configuration.layers pkg_num = "%s" % len( self.builder.package_model.get_selected_packages()) log_file = self.builder.current_logfile else: pkg_num = "N/A" log_file = None # remove for button_id, button in self.button_ids.items(): button.disconnect(button_id) self._remove_all_widget() # repack self.pack_start(self.details_top_buttons, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.build_result = None if self.image_saved or (self.build_succeeded and self.builder.current_step == self.builder.IMAGE_GENERATING): # building is the previous step icon = gtk.Image() pixmap_path = hic.ICON_INDI_CONFIRM_FILE color = HobColors.RUNNING pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path) icon.set_from_pixbuf(pix_buffer) varlist = [""] if self.image_saved: vallist = ["Your image recipe has been saved"] else: vallist = ["Your image is ready"] self.build_result = self.BuildDetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) self.box_group_area.pack_start(self.build_result, expand=False, fill=False) self.buttonlist = [ "Build new image", "Save image recipe", "Run image", "Deploy image" ] # Name self.image_store = [] self.toggled_image = "" default_image_size = 0 self.num_toggled = 0 i = 0 for image_name in image_names: image_size = HobPage._size_to_string( os.stat(os.path.join(image_addr, image_name)).st_size) image_attr = ("run" if (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) else \ ("deploy" if self.test_deployable(image_name) else "")) is_toggled = (image_attr != "") if not self.toggled_image: if i == (len(image_names) - 1): is_toggled = True if is_toggled: default_image_size = image_size self.toggled_image = image_name split_stuff = image_name.split('.') if "rootfs" in split_stuff: image_type = image_name[(len(split_stuff[0]) + len(".rootfs") + 1):] else: image_type = image_name[(len(split_stuff[0]) + 1):] self.image_store.append({ 'name': image_name, 'type': image_type, 'size': image_size, 'is_toggled': is_toggled, 'action_attr': image_attr, }) i = i + 1 self.num_toggled += is_toggled is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image) # Generated image files info varlist = ["Name: ", "Files created: ", "Directory: "] vallist = [] vallist.append(image_name.split('.')[0]) vallist.append(', '.join(fileitem['type'] for fileitem in self.image_store)) vallist.append(image_addr) view_files_button = HobAltButton("View files") view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) view_files_button.set_tooltip_text( "Open the directory containing the image files") open_log_button = None if log_file: open_log_button = HobAltButton("Open log") open_log_button.connect("clicked", self.open_log_clicked_cb, log_file) open_log_button.set_tooltip_text("Open the build's log file") self.image_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=view_files_button, button2=open_log_button) self.box_group_area.pack_start(self.image_detail, expand=False, fill=True) # The default kernel box for the qemu images self.sel_kernel = "" self.kernel_detail = None if 'qemu' in image_name: self.sel_kernel = self.get_kernel_file_name() # varlist = ["Kernel: "] # vallist = [] # vallist.append(self.sel_kernel) # change_kernel_button = HobAltButton("Change") # change_kernel_button.connect("clicked", self.change_kernel_cb) # change_kernel_button.set_tooltip_text("Change qemu kernel file") # self.kernel_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=change_kernel_button) # self.box_group_area.pack_start(self.kernel_detail, expand=True, fill=True) # Machine, Image recipe and Layers layer_num_limit = 15 varlist = ["Machine: ", "Image recipe: ", "Layers: "] vallist = [] self.setting_detail = None if self.build_succeeded: vallist.append(machine) if self.builder.recipe_model.is_custom_image(): if self.builder.configuration.initial_selected_image == self.builder.recipe_model.__custom_image__: base_image = "New image recipe" else: base_image = self.builder.configuration.initial_selected_image + " (edited)" vallist.append(base_image) i = 0 for layer in layers: if i > layer_num_limit: break varlist.append(" - ") i += 1 vallist.append("") i = 0 for layer in layers: if i > layer_num_limit: break elif i == layer_num_limit: vallist.append("and more...") else: vallist.append(layer) i += 1 edit_config_button = HobAltButton("Edit configuration") edit_config_button.set_tooltip_text( "Edit machine and image recipe") edit_config_button.connect("clicked", self.edit_config_button_clicked_cb) self.setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button) self.box_group_area.pack_start(self.setting_detail, expand=True, fill=True) # Packages included, and Total image size varlist = ["Packages included: ", "Total image size: "] vallist = [] vallist.append(pkg_num) vallist.append(default_image_size) self.builder.configuration.image_size = default_image_size self.builder.configuration.image_packages = self.builder.configuration.selected_packages if self.build_succeeded: edit_packages_button = HobAltButton("Edit packages") edit_packages_button.set_tooltip_text( "Edit the packages included in your image") edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb) else: # get to this page from "My images" edit_packages_button = None self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button) self.box_group_area.pack_start(self.package_detail, expand=True, fill=True) # pack the buttons at the bottom, at this time they are already created. if self.build_succeeded: self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) else: # for "My images" page self.details_separator = gtk.HSeparator() self.box_group_area.pack_start(self.details_separator, expand=False, fill=False) self.box_group_area.pack_start(self.details_bottom_buttons, expand=False, fill=False) self.show_all() if self.kernel_detail and (not is_runnable): self.kernel_detail.hide() self.image_saved = False
def show_page(self, step): self.build_succeeded = (step == self.builder.IMAGE_GENERATED) image_addr = self.builder.parameters.image_addr image_names = self.builder.parameters.image_names if self.build_succeeded: machine = self.builder.configuration.curr_mach base_image = self.builder.recipe_model.get_selected_image() layers = self.builder.configuration.layers pkg_num = "%s" % len(self.builder.package_model.get_selected_packages()) log_file = self.builder.current_logfile else: pkg_num = "N/A" log_file = None # remove for button_id, button in self.button_ids.items(): button.disconnect(button_id) self._remove_all_widget() # repack self.pack_start(self.details_top_buttons, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.build_result = None if self.image_saved or (self.build_succeeded and self.builder.current_step == self.builder.IMAGE_GENERATING): # building is the previous step icon = gtk.Image() pixmap_path = hic.ICON_INDI_CONFIRM_FILE color = HobColors.RUNNING pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path) icon.set_from_pixbuf(pix_buffer) varlist = [""] if self.image_saved: vallist = ["Your image recipe has been saved"] else: vallist = ["Your image is ready"] self.build_result = self.BuildDetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) self.box_group_area.pack_start(self.build_result, expand=False, fill=False) self.buttonlist = ["Build new image", "Save image recipe", "Run image", "Deploy image"] # Name self.image_store = [] self.toggled_image = "" default_image_size = 0 self.num_toggled = 0 i = 0 for image_name in image_names: image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) image_attr = ("run" if (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) else \ ("deploy" if self.test_deployable(image_name) else "")) is_toggled = (image_attr != "") if not self.toggled_image: if i == (len(image_names) - 1): is_toggled = True if is_toggled: default_image_size = image_size self.toggled_image = image_name split_stuff = image_name.split('.') if "rootfs" in split_stuff: image_type = image_name[(len(split_stuff[0]) + len(".rootfs") + 1):] else: image_type = image_name[(len(split_stuff[0]) + 1):] self.image_store.append({'name': image_name, 'type': image_type, 'size': image_size, 'is_toggled': is_toggled, 'action_attr': image_attr,}) i = i + 1 self.num_toggled += is_toggled is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image) # Generated image files info varlist = ["Name: ", "Files created: ", "Directory: "] vallist = [] vallist.append(image_name.split('.')[0]) vallist.append(', '.join(fileitem['type'] for fileitem in self.image_store)) vallist.append(image_addr) view_files_button = HobAltButton("View files") view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) view_files_button.set_tooltip_text("Open the directory containing the image files") open_log_button = None if log_file: open_log_button = HobAltButton("Open log") open_log_button.connect("clicked", self.open_log_clicked_cb, log_file) open_log_button.set_tooltip_text("Open the build's log file") self.image_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=view_files_button, button2=open_log_button) self.box_group_area.pack_start(self.image_detail, expand=False, fill=True) # The default kernel box for the qemu images self.sel_kernel = "" self.kernel_detail = None if 'qemu' in image_name: self.sel_kernel = self.get_kernel_file_name() # varlist = ["Kernel: "] # vallist = [] # vallist.append(self.sel_kernel) # change_kernel_button = HobAltButton("Change") # change_kernel_button.connect("clicked", self.change_kernel_cb) # change_kernel_button.set_tooltip_text("Change qemu kernel file") # self.kernel_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=change_kernel_button) # self.box_group_area.pack_start(self.kernel_detail, expand=True, fill=True) # Machine, Image recipe and Layers layer_num_limit = 15 varlist = ["Machine: ", "Image recipe: ", "Layers: "] vallist = [] self.setting_detail = None if self.build_succeeded: vallist.append(machine) if self.builder.recipe_model.is_custom_image(): if self.builder.configuration.initial_selected_image == self.builder.recipe_model.__custom_image__: base_image ="New image recipe" else: base_image = self.builder.configuration.initial_selected_image + " (edited)" vallist.append(base_image) i = 0 for layer in layers: if i > layer_num_limit: break varlist.append(" - ") i += 1 vallist.append("") i = 0 for layer in layers: if i > layer_num_limit: break elif i == layer_num_limit: vallist.append("and more...") else: vallist.append(layer) i += 1 edit_config_button = HobAltButton("Edit configuration") edit_config_button.set_tooltip_text("Edit machine and image recipe") edit_config_button.connect("clicked", self.edit_config_button_clicked_cb) self.setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button) self.box_group_area.pack_start(self.setting_detail, expand=True, fill=True) # Packages included, and Total image size varlist = ["Packages included: ", "Total image size: "] vallist = [] vallist.append(pkg_num) vallist.append(default_image_size) self.builder.configuration.image_size = default_image_size self.builder.configuration.image_packages = self.builder.configuration.selected_packages if self.build_succeeded: edit_packages_button = HobAltButton("Edit packages") edit_packages_button.set_tooltip_text("Edit the packages included in your image") edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb) else: # get to this page from "My images" edit_packages_button = None self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button) self.box_group_area.pack_start(self.package_detail, expand=True, fill=True) # pack the buttons at the bottom, at this time they are already created. if self.build_succeeded: self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) else: # for "My images" page self.details_separator = gtk.HSeparator() self.box_group_area.pack_start(self.details_separator, expand=False, fill=False) self.box_group_area.pack_start(self.details_bottom_buttons, expand=False, fill=False) self.show_all() if self.kernel_detail and (not is_runnable): self.kernel_detail.hide() self.image_saved = False
def show_page(self, step): self.build_succeeded = (step == self.builder.IMAGE_GENERATED) image_addr = self.builder.parameters.image_addr image_names = self.builder.parameters.image_names if self.build_succeeded: machine = self.builder.configuration.curr_mach base_image = self.builder.recipe_model.get_selected_image() pkg_num = "%s" % len( self.builder.package_model.get_selected_packages()) log_file = self.builder.current_logfile else: pkg_num = "N/A" log_file = None # remove for button_id, button in self.button_ids.items(): button.disconnect(button_id) self._remove_all_widget() # repack self.pack_start(self.group_align, expand=True, fill=True) self.build_result = None if self.build_succeeded and self.builder.current_step == self.builder.IMAGE_GENERATING: # building is the previous step icon = gtk.Image() pixmap_path = hic.ICON_INDI_CONFIRM_FILE color = HobColors.RUNNING pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path) icon.set_from_pixbuf(pix_buffer) varlist = [""] vallist = ["Your image is ready"] self.build_result = self.BuildDetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) self.box_group_area.pack_start(self.build_result, expand=False, fill=False) self.buttonlist = ["New image", "Edit packages"] if self.builder.configuration.selected_image == self.builder.recipe_model.__custom_image__: img_recipe_name = "Custom " + self.builder.configuration.initial_selected_image else: img_recipe_name = self.builder.configuration.selected_image if "spi" not in img_recipe_name: self.buttonlist.append("Deploy image") # Name self.image_store = [] self.toggled_image = "" default_image_size = 0 self.num_toggled = 0 i = 0 for image_name in image_names: image_size = HobPage._size_to_string( os.stat(os.path.join(image_addr, image_name)).st_size) image_attr = ("run" if (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) else \ ("deploy" if self.test_deployable(image_name) else "")) is_toggled = (image_attr != "") if not self.toggled_image: if i == (len(image_names) - 1): is_toggled = True if is_toggled: default_image_size = image_size self.toggled_image = image_name split_stuff = image_name.split('.') if "rootfs" in split_stuff: image_type = image_name[(len(split_stuff[0]) + len(".rootfs") + 1):] else: image_type = image_name[(len(split_stuff[0]) + 1):] self.image_store.append({ 'name': image_name, 'type': image_type, 'size': image_size, 'is_toggled': is_toggled, 'action_attr': image_attr, }) i = i + 1 self.num_toggled += is_toggled is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image) table = gtk.Table(40, 40, True) image_info_label = self.create_label( "<span weight='bold' font_desc='15'>Image information</span>") table.attach(image_info_label, 0, 40, 0, 3) image_label = self.create_label( "<span weight='bold' font_desc='12'>Image</span>") table.attach(image_label, 0, 40, 3, 5) image_name_label = self.create_label("<span font_desc='12'>%s</span>" % img_recipe_name) table.attach(image_name_label, 2, 40, 5, 7) distro_label = self.create_label( "<span weight='bold' font_desc='12'>Toolchain</span>") table.attach(distro_label, 0, 40, 7, 9) if self.builder.configuration.toolchain_build: text = "Yes" else: text = "No" distro_name_label = self.create_label( "<span font_desc='12'>%s</span>" % text) table.attach(distro_name_label, 2, 40, 9, 11) packages_label = self.create_label( "<span weight='bold' font_desc='12'>Packages included</span>") table.attach(packages_label, 0, 40, 11, 13) pkg_num_label = self.create_label("<span font_desc='12'>%s</span>" % pkg_num) table.attach(pkg_num_label, 2, 40, 13, 15) files_label = self.create_label( "<span weight='bold' font_desc='12'>Root file system files</span>") table.attach(files_label, 0, 40, 15, 17) textWindow = gtk.ScrolledWindow() textWindow.set_shadow_type(gtk.SHADOW_IN) textWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) msgView = gtk.TextView() msgView.set_editable(False) msgView.set_cursor_visible(False) msgView.set_size_request(-1, 70) msg = image_name + " (" + default_image_size + ")" msg += "\n\nRoot file system files are stored in\n%s" % image_addr buf = gtk.TextBuffer() buf.set_text(msg) msgView.set_buffer(buf) textWindow.add(msgView) msgView.show() table.attach(textWindow, 2, 40, 17, 21) self.box_group_area.pack_start(table, expand=False, fill=True) self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) self.show_all()
def show_page(self, step): self.build_succeeded = (step == self.builder.IMAGE_GENERATED) image_addr = self.builder.parameters.image_addr image_names = self.builder.parameters.image_names if self.build_succeeded: machine = self.builder.configuration.curr_mach base_image = self.builder.recipe_model.get_selected_image() pkg_num = "%s" % len(self.builder.package_model.get_selected_packages()) log_file = self.builder.current_logfile else: pkg_num = "N/A" log_file = None # remove for button_id, button in self.button_ids.items(): button.disconnect(button_id) self._remove_all_widget() # repack self.pack_start(self.group_align, expand=True, fill=True) self.build_result = None if self.build_succeeded and self.builder.current_step == self.builder.IMAGE_GENERATING: # building is the previous step icon = gtk.Image() pixmap_path = hic.ICON_INDI_CONFIRM_FILE color = HobColors.RUNNING pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path) icon.set_from_pixbuf(pix_buffer) varlist = [""] vallist = ["Your image is ready"] self.build_result = self.BuildDetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) self.box_group_area.pack_start(self.build_result, expand=False, fill=False) self.buttonlist = ["New image", "Edit packages"] if self.builder.configuration.selected_image == self.builder.recipe_model.__custom_image__: img_recipe_name = "Custom " + self.builder.configuration.initial_selected_image else: img_recipe_name = self.builder.configuration.selected_image if "spi" not in img_recipe_name: self.buttonlist.append("Deploy image") # Name self.image_store = [] self.toggled_image = "" default_image_size = 0 self.num_toggled = 0 i = 0 for image_name in image_names: image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) image_attr = ("run" if (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) else \ ("deploy" if self.test_deployable(image_name) else "")) is_toggled = (image_attr != "") if not self.toggled_image: if i == (len(image_names) - 1): is_toggled = True if is_toggled: default_image_size = image_size self.toggled_image = image_name split_stuff = image_name.split('.') if "rootfs" in split_stuff: image_type = image_name[(len(split_stuff[0]) + len(".rootfs") + 1):] else: image_type = image_name[(len(split_stuff[0]) + 1):] self.image_store.append({'name': image_name, 'type': image_type, 'size': image_size, 'is_toggled': is_toggled, 'action_attr': image_attr,}) i = i + 1 self.num_toggled += is_toggled is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image) table = gtk.Table(40, 40, True) image_info_label = self.create_label("<span weight='bold' font_desc='15'>Image information</span>") table.attach(image_info_label, 0, 40, 0, 3) image_label = self.create_label("<span weight='bold' font_desc='12'>Image</span>") table.attach(image_label, 0, 40, 3, 5) image_name_label = self.create_label("<span font_desc='12'>%s</span>" % img_recipe_name) table.attach(image_name_label, 2, 40, 5, 7) distro_label = self.create_label("<span weight='bold' font_desc='12'>Toolchain</span>") table.attach(distro_label, 0, 40, 7, 9) if self.builder.configuration.toolchain_build: text = "Yes" else: text ="No" distro_name_label = self.create_label("<span font_desc='12'>%s</span>" % text) table.attach(distro_name_label, 2, 40, 9, 11) packages_label = self.create_label("<span weight='bold' font_desc='12'>Packages included</span>") table.attach(packages_label, 0, 40, 11, 13) pkg_num_label = self.create_label("<span font_desc='12'>%s</span>" % pkg_num) table.attach(pkg_num_label, 2, 40, 13, 15) files_label = self.create_label("<span weight='bold' font_desc='12'>Root file system files</span>") table.attach(files_label, 0, 40, 15, 17) textWindow = gtk.ScrolledWindow() textWindow.set_shadow_type(gtk.SHADOW_IN) textWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) msgView = gtk.TextView() msgView.set_editable(False) msgView.set_cursor_visible(False) msgView.set_size_request(-1, 70) msg = image_name + " (" + default_image_size + ")" msg += "\n\nRoot file system files are stored in\n%s" % image_addr buf = gtk.TextBuffer() buf.set_text(msg) msgView.set_buffer(buf) textWindow.add(msgView) msgView.show() table.attach(textWindow, 2, 40, 17, 21) self.box_group_area.pack_start(table, expand=False, fill=True) self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) self.show_all()
def show_page(self, step): build_succeeded = (step == self.builder.IMAGE_GENERATED) image_addr = self.builder.parameters.image_addr image_names = self.builder.parameters.image_names if build_succeeded: machine = self.builder.configuration.curr_mach base_image = self.builder.recipe_model.get_selected_image() layers = self.builder.configuration.layers pkg_num = "%s" % len(self.builder.package_model.get_selected_packages()) else: pkg_num = "N/A" # remove for button_id, button in self.button_ids.items(): button.disconnect(button_id) self._remove_all_widget() # repack self.pack_start(self.details_top_buttons, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.build_result = None if build_succeeded: # building is the previous step icon = gtk.Image() pixmap_path = hic.ICON_INDI_CONFIRM_FILE color = HobColors.RUNNING pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path) icon.set_from_pixbuf(pix_buffer) varlist = [""] vallist = ["Your image is ready"] self.build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) self.box_group_area.pack_start(self.build_result, expand=False, fill=False) # create the buttons at the bottom first because the buttons are used in apply_button_per_image() if build_succeeded: self.buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"] else: # get to this page from "My images" self.buttonlist = ["Build new image", "Run image", "Deploy image"] # Name varlist = [""] vallist = ["Listed generated image and package files."] t = '' self.image_store.clear() default_toggled = False default_image_size = 0 i = 0 for image_name in image_names: 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) if i == (len(image_names) - 1): default_toggled = True self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, default_toggled) if default_toggled: default_image_size = image_size self.create_bottom_buttons(self.buttonlist, image_name) if 'qemu' in image_name: t = ' (Selected QEMU items to be as runnable image)' else: t = ' (Selected Targeted item to be deploy)' else: self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False) i = i + 1 if build_succeeded: varlist = ["Name: ", "Directory: ", ". "] vallist = [] vallist.append(image_name.split('.')[0]) vallist.append(image_addr) vallist.append(t) image_table = None else: image_table = HobViewTable(self.__columns__) image_table.set_model(self.image_store) image_table.connect("row-activated", self.row_activated_cb) if default_image_size and ('qemu' in image_name): t = '\n(Selected QEMU items to be as runnable image, so you need to select prompted kernel to run)' vallist[0] += t view_files_button = HobAltButton("View files") view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) view_files_button.set_tooltip_text("Open the directory containing the image files") self.image_detail = self.DetailBox(widget=image_table, varlist=varlist, vallist=vallist, button=view_files_button) self.box_group_area.pack_start(self.image_detail, expand=True, fill=True) # Machine, Base image and Layers layer_num_limit = 15 varlist = ["Machine: ", "Base image: ", "Layers: "] vallist = [] self.setting_detail = None if build_succeeded: vallist.append(machine) vallist.append(base_image) i = 0 for layer in layers: varlist.append(" - ") if i > layer_num_limit: break i += 1 vallist.append("") i = 0 for layer in layers: if i > layer_num_limit: break elif i == layer_num_limit: vallist.append("and more...") else: vallist.append(layer) i += 1 edit_config_button = HobAltButton("Edit configuration") edit_config_button.set_tooltip_text("Edit machine, base image and recipes") edit_config_button.connect("clicked", self.edit_config_button_clicked_cb) self.setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button) self.box_group_area.pack_start(self.setting_detail, expand=True, fill=True) # Packages included, and Total image size varlist = ["Packages included: ", "Total image size: "] vallist = [] vallist.append(pkg_num) vallist.append(default_image_size) if build_succeeded: edit_packages_button = HobAltButton("Edit packages") edit_packages_button.set_tooltip_text("Edit the packages included in your image") edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb) else: # get to this page from "My images" edit_packages_button = None self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button) self.box_group_area.pack_start(self.package_detail, expand=False, fill=False) # pack the buttons at the bottom, at this time they are already created. self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) self.show_all()
def show_page(self, step): build_succeeded = (step == self.builder.IMAGE_GENERATED) image_addr = self.builder.parameters.image_addr image_names = self.builder.parameters.image_names if build_succeeded: machine = self.builder.configuration.curr_mach base_image = self.builder.recipe_model.get_selected_image() layers = self.builder.configuration.layers pkg_num = "%s" % len(self.builder.package_model.get_selected_packages()) else: pkg_num = "N/A" # remove for button_id, button in self.button_ids.items(): button.disconnect(button_id) self._remove_all_widget() # repack self.pack_start(self.details_top_buttons, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.build_result = None if build_succeeded: # building is the previous step icon = gtk.Image() pixmap_path = hic.ICON_INDI_CONFIRM_FILE color = HobColors.RUNNING pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path) icon.set_from_pixbuf(pix_buffer) varlist = [""] vallist = ["Your image is ready"] self.build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) self.box_group_area.pack_start(self.build_result, expand=False, fill=False) # create the buttons at the bottom first because the buttons are used in apply_button_per_image() if build_succeeded: self.buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"] else: # get to this page from "My images" self.buttonlist = ["Build new image", "Run image", "Deploy image"] # Name self.image_store.clear() default_toggled = False default_image_size = 0 i = 0 for image_name in image_names: 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) if i == (len(image_names) - 1): default_toggled = True self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, default_toggled) if default_toggled: default_image_size = image_size self.create_bottom_buttons(self.buttonlist, image_name) else: self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False) i = i + 1 image_table = HobViewTable(self.__columns__) image_table.set_model(self.image_store) image_table.connect("toggled", self.toggled_cb) view_files_button = HobAltButton("View files") view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) view_files_button.set_tooltip_text("Open the directory containing the image files") self.image_detail = self.DetailBox(widget=image_table, button=view_files_button) self.box_group_area.pack_start(self.image_detail, expand=True, fill=True) # Machine, Base image and Layers layer_num_limit = 15 varlist = ["Machine: ", "Base image: ", "Layers: "] vallist = [] self.setting_detail = None if build_succeeded: vallist.append(machine) vallist.append(base_image) i = 0 for layer in layers: varlist.append(" - ") if i > layer_num_limit: break i += 1 vallist.append("") i = 0 for layer in layers: if i > layer_num_limit: break elif i == layer_num_limit: vallist.append("and more...") else: vallist.append(layer) i += 1 edit_config_button = HobAltButton("Edit configuration") edit_config_button.set_tooltip_text("Edit machine, base image and recipes") edit_config_button.connect("clicked", self.edit_config_button_clicked_cb) self.setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button) self.box_group_area.pack_start(self.setting_detail, expand=False, fill=False) # Packages included, and Total image size varlist = ["Packages included: ", "Total image size: "] vallist = [] vallist.append(pkg_num) vallist.append(default_image_size) if build_succeeded: edit_packages_button = HobAltButton("Edit packages") edit_packages_button.set_tooltip_text("Edit the packages included in your image") edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb) else: # get to this page from "My images" edit_packages_button = None self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button) self.box_group_area.pack_start(self.package_detail, expand=False, fill=False) # pack the buttons at the bottom, at this time they are already created. self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) self.show_all()