class BuildDetailsPage(HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0, ) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.task_status = gtk.Label("\n") # to ensure layout is correct self.task_status.set_alignment(0.0, 0.5) self.progress_box.pack_start(self.task_status, expand=False, fill=False) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) self.stop_button.set_sensitive(False) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.notebook = HobNotebook() self.config_tv = BuildConfigurationTreeView() self.scrolled_view_config = gtk.ScrolledWindow() self.scrolled_view_config.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_config.add(self.config_tv) self.notebook.append_page(self.scrolled_view_config, "Build configuration") self.failure_tv = BuildFailureTreeView() self.failure_model = self.builder.handler.build.model.failure_model() self.failure_tv.set_model(self.failure_model) self.scrolled_view_failure = gtk.ScrolledWindow() self.scrolled_view_failure.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_failure.add(self.failure_tv) self.notebook.append_page(self.scrolled_view_failure, "Issues") self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow() self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.notebook.append_page(self.scrolled_view_build, "Log") self.builder.handler.build.model.connect_after( "row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton('<< Back') self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def update_build_status(self, current, total, task): recipe_path, recipe_task = task.split(", ") recipe = os.path.basename(recipe_path).rstrip(".bb") tsk_msg = "<b>Running task %s of %s:</b> %s\n<b>Recipe:</b> %s" % ( current, total, recipe_task, recipe) self.task_status.set_markup(tsk_msg) self.stop_button.set_sensitive(True) def reset_build_status(self): self.task_status.set_markup("\n") # to ensure layout is correct self.endpath = (0, ) def show_issues(self): self.num_of_issues += 1 self.notebook.show_indicator_icon("Issues", self.num_of_issues) def reset_issues(self): self.num_of_issues = 0 self.notebook.hide_indicator_icon("Issues") def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def add_build_fail_top_bar(self, actions, log_file=None): primary_action = "Edit %s" % actions color = HobColors.ERROR build_fail_top = gtk.EventBox() #build_fail_top.set_size_request(-1, 200) build_fail_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_fail_tab = gtk.Table(14, 46, True) build_fail_top.add(build_fail_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file( hic.ICON_INDI_ERROR_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_fail_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_fail_tab.attach(label, 4, 26, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) # Ensure variable disk_full is defined if not hasattr(self.builder, 'disk_full'): self.builder.disk_full = False if self.builder.disk_full: markup = "<span size='medium'>There is no disk space left, so Hob cannot finish building your image. Free up some disk space\n" markup += "and restart the build. Check the \"Issues\" tab for more details</span>" label.set_markup(markup) else: label.set_markup( "<span size='medium'>Check the \"Issues\" information for more details</span>" ) build_fail_tab.attach(label, 4, 40, 4, 9) # create button 'Edit packages' action_button = HobButton(primary_action) #action_button.set_size_request(-1, 40) action_button.set_tooltip_text("Edit the %s parameters" % actions) action_button.connect('clicked', self.failure_primary_action_button_clicked_cb, primary_action) if log_file: open_log_button = HobAltButton("Open log") open_log_button.set_relief(gtk.RELIEF_HALF) open_log_button.set_tooltip_text("Open the build's log file") open_log_button.connect('clicked', self.open_log_button_clicked_cb, log_file) attach_pos = (24 if log_file else 14) file_bug_button = HobAltButton('File a bug') file_bug_button.set_relief(gtk.RELIEF_HALF) file_bug_button.set_tooltip_text( "Open the Yocto Project bug tracking website") file_bug_button.connect('clicked', self.failure_activate_file_bug_link_cb) if not self.builder.disk_full: build_fail_tab.attach(action_button, 4, 13, 9, 12) if log_file: build_fail_tab.attach(open_log_button, 14, 23, 9, 12) build_fail_tab.attach(file_bug_button, attach_pos, attach_pos + 9, 9, 12) else: restart_build = HobButton("Restart the build") restart_build.set_tooltip_text("Restart the build") restart_build.connect('clicked', self.restart_build_button_clicked_cb) build_fail_tab.attach(restart_build, 4, 13, 9, 12) build_fail_tab.attach(action_button, 14, 23, 9, 12) if log_file: build_fail_tab.attach(open_log_button, attach_pos, attach_pos + 9, 9, 12) self.builder.disk_full = False return build_fail_top def show_fail_page(self, title): self._remove_all_widget() self.title = "Hob cannot build your %s" % title self.build_fail_bar = self.add_build_fail_top_bar( title, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_fail_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.show_all() self.notebook.set_page("Issues") self.back_button.hide() def add_build_stop_top_bar(self, action, log_file=None): color = HobColors.LIGHT_GRAY build_stop_top = gtk.EventBox() #build_stop_top.set_size_request(-1, 200) build_stop_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_stop_top.set_flags(gtk.CAN_DEFAULT) build_stop_top.grab_default() build_stop_tab = gtk.Table(11, 46, True) build_stop_top.add(build_stop_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file( hic.ICON_INFO_HOVER_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_stop_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_stop_tab.attach(label, 4, 26, 0, 6) action_button = HobButton("Edit %s" % action) action_button.set_size_request(-1, 40) if action == "image": action_button.set_tooltip_text("Edit the image parameters") elif action == "recipes": action_button.set_tooltip_text("Edit the included recipes") elif action == "packages": action_button.set_tooltip_text("Edit the included packages") action_button.connect('clicked', self.stop_primary_action_button_clicked_cb, action) build_stop_tab.attach(action_button, 4, 13, 6, 9) if log_file: open_log_button = HobAltButton("Open log") open_log_button.set_relief(gtk.RELIEF_HALF) open_log_button.set_tooltip_text("Open the build's log file") open_log_button.connect('clicked', self.open_log_button_clicked_cb, log_file) build_stop_tab.attach(open_log_button, 14, 23, 6, 9) attach_pos = (24 if log_file else 14) build_button = HobAltButton("Build new image") #build_button.set_size_request(-1, 40) build_button.set_tooltip_text("Create a new image from scratch") build_button.connect('clicked', self.new_image_button_clicked_cb) build_stop_tab.attach(build_button, attach_pos, attach_pos + 9, 6, 9) return build_stop_top, action_button def show_stop_page(self, action): self._remove_all_widget() self.title = "Build stopped" self.build_stop_bar, action_button = self.add_build_stop_top_bar( action, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_stop_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.show_all() self.back_button.hide() return action_button def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.config_tv.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.notebook.set_page("Log") self.back_button.hide() self.reset_build_status() self.reset_issues() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def new_image_button_clicked_cb(self, button): self.builder.reset() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[ 0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def show_configurations(self, configurations, params): self.config_tv.show(configurations, params) def failure_primary_action_button_clicked_cb(self, button, action): if "Edit recipes" in action: self.builder.show_recipes() elif "Edit packages" in action: self.builder.show_packages() elif "Edit image" in action: self.builder.show_configuration() def restart_build_button_clicked_cb(self, button): self.builder.just_bake() def stop_primary_action_button_clicked_cb(self, button, action): if "recipes" in action: self.builder.show_recipes() elif "packages" in action: self.builder.show_packages(ask=False) elif "image" in action: self.builder.show_configuration() def open_log_button_clicked_cb(self, button, log_file): if log_file: self.stop = False dialog = OpeningLogDialog(title="Opening Log", parent=None, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR) #create a thread to open log file background = OpeningLogThread(dialog, log_file, self) background.start() response = dialog.run() self.stop = True background.join() def failure_activate_file_bug_link_cb(self, button): button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")
class BuildDetailsPage (HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0,) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.task_status = gtk.Label("\n") # to ensure layout is correct self.task_status.set_alignment(0.0, 0.5) self.progress_box.pack_start(self.task_status, expand=False, fill=False) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) self.stop_button.set_sensitive(False) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.notebook = HobNotebook() self.config_tv = BuildConfigurationTreeView() self.scrolled_view_config = gtk.ScrolledWindow () self.scrolled_view_config.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_config.add(self.config_tv) self.notebook.append_page(self.scrolled_view_config, "Build configuration") self.failure_tv = BuildFailureTreeView() self.failure_model = self.builder.handler.build.model.failure_model() self.failure_tv.set_model(self.failure_model) self.scrolled_view_failure = gtk.ScrolledWindow () self.scrolled_view_failure.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_failure.add(self.failure_tv) self.notebook.append_page(self.scrolled_view_failure, "Issues") self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow () self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.notebook.append_page(self.scrolled_view_build, "Log") self.builder.handler.build.model.connect_after("row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton('<< Back') self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def update_build_status(self, current, total, task): recipe_path, recipe_task = task.split(", ") recipe = os.path.basename(recipe_path).rstrip(".bb") tsk_msg = "<b>Running task %s of %s:</b> %s\n<b>Recipe:</b> %s" % (current, total, recipe_task, recipe) self.task_status.set_markup(tsk_msg) self.stop_button.set_sensitive(True) def reset_build_status(self): self.task_status.set_markup("\n") # to ensure layout is correct self.endpath = (0,) def show_issues(self): self.num_of_issues += 1 self.notebook.show_indicator_icon("Issues", self.num_of_issues) def reset_issues(self): self.num_of_issues = 0 self.notebook.hide_indicator_icon("Issues") def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def add_build_fail_top_bar(self, actions, log_file=None): primary_action = "Edit %s" % actions color = HobColors.ERROR build_fail_top = gtk.EventBox() #build_fail_top.set_size_request(-1, 200) build_fail_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_fail_tab = gtk.Table(14, 46, True) build_fail_top.add(build_fail_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ERROR_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_fail_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_fail_tab.attach(label, 4, 26, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) # Ensure variable disk_full is defined if not hasattr(self.builder, 'disk_full'): self.builder.disk_full = False if self.builder.disk_full: markup = "<span size='medium'>There is no disk space left, so Hob cannot finish building your image. Free up some disk space\n" markup += "and restart the build. Check the \"Issues\" tab for more details</span>" label.set_markup(markup) else: label.set_markup("<span size='medium'>Check the \"Issues\" information for more details</span>") build_fail_tab.attach(label, 4, 40, 4, 9) # create button 'Edit packages' action_button = HobButton(primary_action) #action_button.set_size_request(-1, 40) action_button.set_tooltip_text("Edit the %s parameters" % actions) action_button.connect('clicked', self.failure_primary_action_button_clicked_cb, primary_action) if log_file: open_log_button = HobAltButton("Open log") open_log_button.set_relief(gtk.RELIEF_HALF) open_log_button.set_tooltip_text("Open the build's log file") open_log_button.connect('clicked', self.open_log_button_clicked_cb, log_file) attach_pos = (24 if log_file else 14) file_bug_button = HobAltButton('File a bug') file_bug_button.set_relief(gtk.RELIEF_HALF) file_bug_button.set_tooltip_text("Open the Yocto Project bug tracking website") file_bug_button.connect('clicked', self.failure_activate_file_bug_link_cb) if not self.builder.disk_full: build_fail_tab.attach(action_button, 4, 13, 9, 12) if log_file: build_fail_tab.attach(open_log_button, 14, 23, 9, 12) build_fail_tab.attach(file_bug_button, attach_pos, attach_pos + 9, 9, 12) else: restart_build = HobButton("Restart the build") restart_build.set_tooltip_text("Restart the build") restart_build.connect('clicked', self.restart_build_button_clicked_cb) build_fail_tab.attach(restart_build, 4, 13, 9, 12) build_fail_tab.attach(action_button, 14, 23, 9, 12) if log_file: build_fail_tab.attach(open_log_button, attach_pos, attach_pos + 9, 9, 12) self.builder.disk_full = False return build_fail_top def show_fail_page(self, title): self._remove_all_widget() self.title = "Hob cannot build your %s" % title self.build_fail_bar = self.add_build_fail_top_bar(title, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_fail_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.show_all() self.notebook.set_page("Issues") self.back_button.hide() def add_build_stop_top_bar(self, action, log_file=None): color = HobColors.LIGHT_GRAY build_stop_top = gtk.EventBox() #build_stop_top.set_size_request(-1, 200) build_stop_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_stop_top.set_flags(gtk.CAN_DEFAULT) build_stop_top.grab_default() build_stop_tab = gtk.Table(11, 46, True) build_stop_top.add(build_stop_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INFO_HOVER_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_stop_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_stop_tab.attach(label, 4, 26, 0, 6) action_button = HobButton("Edit %s" % action) action_button.set_size_request(-1, 40) if action == "image": action_button.set_tooltip_text("Edit the image parameters") elif action == "recipes": action_button.set_tooltip_text("Edit the included recipes") elif action == "packages": action_button.set_tooltip_text("Edit the included packages") action_button.connect('clicked', self.stop_primary_action_button_clicked_cb, action) build_stop_tab.attach(action_button, 4, 13, 6, 9) if log_file: open_log_button = HobAltButton("Open log") open_log_button.set_relief(gtk.RELIEF_HALF) open_log_button.set_tooltip_text("Open the build's log file") open_log_button.connect('clicked', self.open_log_button_clicked_cb, log_file) build_stop_tab.attach(open_log_button, 14, 23, 6, 9) attach_pos = (24 if log_file else 14) build_button = HobAltButton("Build new image") #build_button.set_size_request(-1, 40) build_button.set_tooltip_text("Create a new image from scratch") build_button.connect('clicked', self.new_image_button_clicked_cb) build_stop_tab.attach(build_button, attach_pos, attach_pos + 9, 6, 9) return build_stop_top, action_button def show_stop_page(self, action): self._remove_all_widget() self.title = "Build stopped" self.build_stop_bar, action_button = self.add_build_stop_top_bar(action, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_stop_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.show_all() self.back_button.hide() return action_button def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.config_tv.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.notebook.set_page("Log") self.back_button.hide() self.reset_build_status() self.reset_issues() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def new_image_button_clicked_cb(self, button): self.builder.reset() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def show_configurations(self, configurations, params): self.config_tv.show(configurations, params) def failure_primary_action_button_clicked_cb(self, button, action): if "Edit recipes" in action: self.builder.show_recipes() elif "Edit packages" in action: self.builder.show_packages() elif "Edit image" in action: self.builder.show_configuration() def restart_build_button_clicked_cb(self, button): self.builder.just_bake() def stop_primary_action_button_clicked_cb(self, button, action): if "recipes" in action: self.builder.show_recipes() elif "packages" in action: self.builder.show_packages(ask=False) elif "image" in action: self.builder.show_configuration() def open_log_button_clicked_cb(self, button, log_file): if log_file: self.stop = False dialog = OpeningLogDialog(title = "Opening Log", parent = None, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR) #create a thread to open log file background = OpeningLogThread(dialog, log_file, self) background.start() response = dialog.run() self.stop = True background.join() def failure_activate_file_bug_link_cb(self, button): button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")
def create_bottom_buttons(self, buttonlist, image_name): # Create the buttons at the bottom created = False packed = False self.button_ids = {} is_runnable = False # create button "Deploy image" name = "Deploy image" if name in buttonlist and self.test_deployable(image_name): deploy_button = HobButton('Deploy image') #deploy_button.set_size_request(205, 49) deploy_button.set_tooltip_text( "Burn a live image to a USB drive or flash memory") deploy_button.set_flags(gtk.CAN_DEFAULT) button_id = deploy_button.connect("clicked", self.deploy_button_clicked_cb) self.button_ids[button_id] = deploy_button self.details_bottom_buttons.pack_end(deploy_button, expand=False, fill=False) created = True packed = True name = "Run image" if name in buttonlist and self.test_type_runnable( image_name) and self.test_mach_runnable(image_name): if created == True: # separator #label = gtk.Label(" or ") #self.details_bottom_buttons.pack_end(label, expand=False, fill=False) # create button "Run image" run_button = HobAltButton("Run image") else: # create button "Run image" as the primary button run_button = HobButton("Run image") #run_button.set_size_request(205, 49) run_button.set_flags(gtk.CAN_DEFAULT) packed = True run_button.set_tooltip_text("Start up an image with qemu emulator") button_id = run_button.connect("clicked", self.run_button_clicked_cb) self.button_ids[button_id] = run_button self.details_bottom_buttons.pack_end(run_button, expand=False, fill=False) created = True is_runnable = True name = "Save image recipe" if name in buttonlist and self.builder.recipe_model.is_custom_image(): save_button = HobAltButton("Save image recipe") save_button.set_tooltip_text( "Keep your changes saving them as an image recipe") save_button.set_sensitive(not self.image_saved) button_id = save_button.connect("clicked", self.save_button_clicked_cb) self.button_ids[button_id] = save_button self.details_bottom_buttons.pack_end(save_button, expand=False, fill=False) name = "Build new image" if name in buttonlist: # create button "Build new image" if packed: build_new_button = HobAltButton("Build new image") else: build_new_button = HobButton("Build new image") build_new_button.set_flags(gtk.CAN_DEFAULT) #build_new_button.set_size_request(205, 49) self.details_bottom_buttons.pack_end(build_new_button, expand=False, fill=False) build_new_button.set_tooltip_text( "Create a new image from scratch") button_id = build_new_button.connect( "clicked", self.build_new_button_clicked_cb) self.button_ids[button_id] = build_new_button return is_runnable
class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): (BUILD_ENV_PAGE_ID, SHARED_STATE_PAGE_ID, PROXIES_PAGE_ID, OTHERS_PAGE_ID) = range(4) (TEST_NETWORK_NONE, TEST_NETWORK_INITIAL, TEST_NETWORK_RUNNING, TEST_NETWORK_PASSED, TEST_NETWORK_FAILED, TEST_NETWORK_CANCELED) = range(6) TARGETS = [ ("MY_TREE_MODEL_ROW", gtk.TARGET_SAME_WIDGET, 0), ("text/plain", 0, 1), ("TEXT", 0, 2), ("STRING", 0, 3), ] def __init__(self, title, configuration, all_image_types, all_package_formats, all_distros, all_sdk_machines, max_threads, parent, flags, handler, buttons=None): super(SimpleSettingsDialog, self).__init__(title, parent, flags, buttons) # class members from other objects # bitbake settings from Builder.Configuration self.configuration = configuration self.image_types = all_image_types self.all_package_formats = all_package_formats self.all_distros = all_distros self.all_sdk_machines = all_sdk_machines self.max_threads = max_threads # class members for internal use self.dldir_text = None self.sstatedir_text = None self.sstatemirrors_list = [] self.sstatemirrors_changed = 0 self.bb_spinner = None self.pmake_spinner = None self.rootfs_size_spinner = None self.extra_size_spinner = None self.gplv3_checkbox = None self.toolchain_checkbox = None self.setting_store = None self.image_types_checkbuttons = {} self.md5 = self.config_md5() self.proxy_md5 = self.config_proxy_md5() self.settings_changed = False self.proxy_settings_changed = False self.handler = handler self.proxy_test_ran = False self.selected_mirror_row = 0 self.new_mirror = False # create visual elements on the dialog self.create_visual_elements() self.connect("response", self.response_cb) def _get_sorted_value(self, var): return " ".join(sorted(str(var).split())) + "\n" def config_proxy_md5(self): data = ("ENABLE_PROXY: " + self._get_sorted_value(self.configuration.enable_proxy)) if self.configuration.enable_proxy: for protocol in self.configuration.proxies.keys(): data += (protocol + ": " + self._get_sorted_value(self.configuration.combine_proxy(protocol))) return hashlib.md5(data).hexdigest() def config_md5(self): data = "" for key in self.configuration.extra_setting.keys(): data += (key + ": " + self._get_sorted_value(self.configuration.extra_setting[key])) return hashlib.md5(data).hexdigest() def gen_proxy_entry_widget(self, protocol, parent, need_button=True, line=0): label = gtk.Label(protocol.upper() + " proxy") self.proxy_table.attach(label, 0, 1, line, line+1, xpadding=24) proxy_entry = gtk.Entry() proxy_entry.set_size_request(300, -1) self.proxy_table.attach(proxy_entry, 1, 2, line, line+1, ypadding=4) self.proxy_table.attach(gtk.Label(":"), 2, 3, line, line+1, xpadding=12, ypadding=4) port_entry = gtk.Entry() port_entry.set_size_request(60, -1) self.proxy_table.attach(port_entry, 3, 4, line, line+1, ypadding=4) details_button = HobAltButton("Details") details_button.connect("clicked", self.details_cb, parent, protocol) self.proxy_table.attach(details_button, 4, 5, line, line+1, xpadding=4, yoptions=gtk.EXPAND) return proxy_entry, port_entry, details_button def refresh_proxy_components(self): self.same_checkbox.set_sensitive(self.configuration.enable_proxy) self.http_proxy.set_text(self.configuration.combine_host_only("http")) self.http_proxy.set_editable(self.configuration.enable_proxy) self.http_proxy.set_sensitive(self.configuration.enable_proxy) self.http_proxy_port.set_text(self.configuration.combine_port_only("http")) self.http_proxy_port.set_editable(self.configuration.enable_proxy) self.http_proxy_port.set_sensitive(self.configuration.enable_proxy) self.http_proxy_details.set_sensitive(self.configuration.enable_proxy) self.https_proxy.set_text(self.configuration.combine_host_only("https")) self.https_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.https_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.https_proxy_port.set_text(self.configuration.combine_port_only("https")) self.https_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.https_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.https_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy.set_text(self.configuration.combine_host_only("ftp")) self.ftp_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy_port.set_text(self.configuration.combine_port_only("ftp")) self.ftp_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy.set_text(self.configuration.combine_host_only("socks")) self.socks_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy_port.set_text(self.configuration.combine_port_only("socks")) self.socks_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy.set_text(self.configuration.combine_host_only("cvs")) self.cvs_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy_port.set_text(self.configuration.combine_port_only("cvs")) self.cvs_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) if self.configuration.same_proxy: if self.http_proxy.get_text(): [w.set_text(self.http_proxy.get_text()) for w in self.same_proxy_addresses] if self.http_proxy_port.get_text(): [w.set_text(self.http_proxy_port.get_text()) for w in self.same_proxy_ports] def proxy_checkbox_toggled_cb(self, button): self.configuration.enable_proxy = self.proxy_checkbox.get_active() if not self.configuration.enable_proxy: self.configuration.same_proxy = False self.same_checkbox.set_active(self.configuration.same_proxy) self.save_proxy_data() self.refresh_proxy_components() def same_checkbox_toggled_cb(self, button): self.configuration.same_proxy = self.same_checkbox.get_active() self.save_proxy_data() self.refresh_proxy_components() def save_proxy_data(self): self.configuration.split_proxy("http", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) if self.configuration.same_proxy: self.configuration.split_proxy("https", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) self.configuration.split_proxy("ftp", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) self.configuration.split_proxy("socks", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) self.configuration.split_proxy("cvs", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) else: self.configuration.split_proxy("https", self.https_proxy.get_text() + ":" + self.https_proxy_port.get_text()) self.configuration.split_proxy("ftp", self.ftp_proxy.get_text() + ":" + self.ftp_proxy_port.get_text()) self.configuration.split_proxy("socks", self.socks_proxy.get_text() + ":" + self.socks_proxy_port.get_text()) self.configuration.split_proxy("cvs", self.cvs_proxy.get_text() + ":" + self.cvs_proxy_port.get_text()) def response_cb(self, dialog, response_id): if response_id == gtk.RESPONSE_YES: if self.proxy_checkbox.get_active(): # Check that all proxy entries have a corresponding port for proxy, port in zip(self.all_proxy_addresses, self.all_proxy_ports): if proxy.get_text() and not port.get_text(): lbl = "<b>Enter all port numbers</b>" msg = "Proxy servers require a port number. Please make sure you have entered a port number for each proxy server." dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_WARNING, msg) button = dialog.add_button("Close", gtk.RESPONSE_OK) HobButton.style_button(button) response = dialog.run() dialog.destroy() self.emit_stop_by_name("response") return self.configuration.dldir = self.dldir_text.get_text() self.configuration.sstatedir = self.sstatedir_text.get_text() self.configuration.sstatemirror = "" for mirror in self.sstatemirrors_list: if mirror[1] != "" and mirror[2].startswith("file://"): if mirror[1].endswith("\\1"): smirror = mirror[2] + " " + mirror[1] + " \\n " else: smirror = mirror[2] + " " + mirror[1] + "\\1 \\n " self.configuration.sstatemirror += smirror self.configuration.bbthread = self.bb_spinner.get_value_as_int() self.configuration.pmake = self.pmake_spinner.get_value_as_int() self.save_proxy_data() self.configuration.extra_setting = {} it = self.setting_store.get_iter_first() while it: key = self.setting_store.get_value(it, 0) value = self.setting_store.get_value(it, 1) self.configuration.extra_setting[key] = value it = self.setting_store.iter_next(it) md5 = self.config_md5() self.settings_changed = (self.md5 != md5) self.proxy_settings_changed = (self.proxy_md5 != self.config_proxy_md5()) def create_build_environment_page(self): advanced_vbox = gtk.VBox(False, 6) advanced_vbox.set_border_width(6) advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Parallel threads</span>'), expand=False, fill=False) sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) label = self.gen_label_widget("BitBake parallel threads") tooltip = "Sets the number of threads that BitBake tasks can simultaneously run. See the <a href=\"" tooltip += "http://www.yoctoproject.org/docs/current/poky-ref-manual/" tooltip += "poky-ref-manual.html#var-BB_NUMBER_THREADS\">Poky reference manual</a> for information" bbthread_widget, self.bb_spinner = self.gen_spinner_widget(self.configuration.bbthread, 1, self.max_threads,"<b>BitBake prallalel threads</b>" + "*" + tooltip) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(bbthread_widget, expand=False, fill=False) sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) label = self.gen_label_widget("Make parallel threads") tooltip = "Sets the maximum number of threads the host can use during the build. See the <a href=\"" tooltip += "http://www.yoctoproject.org/docs/current/poky-ref-manual/" tooltip += "poky-ref-manual.html#var-PARALLEL_MAKE\">Poky reference manual</a> for information" pmake_widget, self.pmake_spinner = self.gen_spinner_widget(self.configuration.pmake, 1, self.max_threads,"<b>Make parallel threads</b>" + "*" + tooltip) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(pmake_widget, expand=False, fill=False) advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Downloaded source code</span>'), expand=False, fill=False) sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) label = self.gen_label_widget("Downloads directory") tooltip = "Select a folder that caches the upstream project source code" dldir_widget, self.dldir_text = self.gen_entry_widget(self.configuration.dldir, self,"<b>Downloaded source code</b>" + "*" + tooltip) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(dldir_widget, expand=False, fill=False) return advanced_vbox def create_shared_state_page(self): advanced_vbox = gtk.VBox(False) advanced_vbox.set_border_width(12) sub_vbox = gtk.VBox(False) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False, padding=24) content = "<span>Shared state directory</span>" tooltip = "Select a folder that caches your prebuilt results" label = self.gen_label_info_widget(content,"<b>Shared state directory</b>" + "*" + tooltip) sstatedir_widget, self.sstatedir_text = self.gen_entry_widget(self.configuration.sstatedir, self) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(sstatedir_widget, expand=False, fill=False, padding=6) content = "<span weight=\"bold\">Shared state mirrors</span>" tooltip = "URLs pointing to pre-built mirrors that will speed your build. " tooltip += "Select the \'Standard\' configuration if the structure of your " tooltip += "mirror replicates the structure of your local shared state directory. " tooltip += "For more information on shared state mirrors, check the <a href=\"" tooltip += "http://www.yoctoproject.org/docs/current/poky-ref-manual/" tooltip += "poky-ref-manual.html#shared-state\">Yocto Project Reference Manual</a>." table = self.gen_label_info_widget(content,"<b>Shared state mirrors</b>" + "*" + tooltip) advanced_vbox.pack_start(table, expand=False, fill=False, padding=6) sub_vbox = gtk.VBox(False) advanced_vbox.pack_start(sub_vbox, gtk.TRUE, gtk.TRUE, 0) if self.sstatemirrors_changed == 0: self.sstatemirrors_changed = 1 sstatemirrors = self.configuration.sstatemirror if sstatemirrors == "": sm_list = ["Standard", "", "file://(.*)"] self.sstatemirrors_list.append(sm_list) else: sstatemirrors = [x for x in sstatemirrors.split('\\n')] for sstatemirror in sstatemirrors: sstatemirror_fields = [x for x in sstatemirror.split(' ') if x.strip()] if len(sstatemirror_fields) == 2: if sstatemirror_fields[0] == "file://(.*)" or sstatemirror_fields[0] == "file://.*": sm_list = ["Standard", sstatemirror_fields[1], sstatemirror_fields[0]] else: sm_list = ["Custom", sstatemirror_fields[1], sstatemirror_fields[0]] self.sstatemirrors_list.append(sm_list) sstatemirrors_widget, sstatemirrors_store = self.gen_shared_sstate_widget(self.sstatemirrors_list, self) sub_vbox.pack_start(sstatemirrors_widget, expand=True, fill=True) table = gtk.Table(1, 10, False) table.set_col_spacings(6) add_mirror_button = HobAltButton("Add mirror") add_mirror_button.connect("clicked", self.add_mirror) add_mirror_button.set_size_request(120,30) table.attach(add_mirror_button, 1, 2, 0, 1, xoptions=gtk.SHRINK) self.delete_button = HobAltButton("Delete mirror") self.delete_button.connect("clicked", self.delete_cb) self.delete_button.set_size_request(120, 30) table.attach(self.delete_button, 3, 4, 0, 1, xoptions=gtk.SHRINK) advanced_vbox.pack_start(table, expand=False, fill=False, padding=6) return advanced_vbox def gen_shared_sstate_widget(self, sstatemirrors_list, window): hbox = gtk.HBox(False) sstatemirrors_store = gtk.ListStore(str, str, str) for sstatemirror in sstatemirrors_list: sstatemirrors_store.append(sstatemirror) self.sstatemirrors_tv = gtk.TreeView() self.sstatemirrors_tv.set_rules_hint(True) self.sstatemirrors_tv.set_headers_visible(True) tree_selection = self.sstatemirrors_tv.get_selection() tree_selection.set_mode(gtk.SELECTION_SINGLE) # Allow enable drag and drop of rows including row move self.sstatemirrors_tv.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, self.TARGETS, gtk.gdk.ACTION_DEFAULT| gtk.gdk.ACTION_MOVE) self.sstatemirrors_tv.enable_model_drag_dest(self.TARGETS, gtk.gdk.ACTION_DEFAULT) self.sstatemirrors_tv.connect("drag_data_get", self.drag_data_get_cb) self.sstatemirrors_tv.connect("drag_data_received", self.drag_data_received_cb) self.scroll = gtk.ScrolledWindow() self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.scroll.set_shadow_type(gtk.SHADOW_IN) self.scroll.connect('size-allocate', self.scroll_changed) self.scroll.add(self.sstatemirrors_tv) #list store for cell renderer m = gtk.ListStore(gobject.TYPE_STRING) m.append(["Standard"]) m.append(["Custom"]) cell0 = gtk.CellRendererCombo() cell0.set_property("model",m) cell0.set_property("text-column", 0) cell0.set_property("editable", True) cell0.set_property("has-entry", False) col0 = gtk.TreeViewColumn("Configuration") col0.pack_start(cell0, False) col0.add_attribute(cell0, "text", 0) col0.set_cell_data_func(cell0, self.configuration_field) self.sstatemirrors_tv.append_column(col0) cell0.connect("edited", self.combo_changed, sstatemirrors_store) self.cell1 = gtk.CellRendererText() self.cell1.set_padding(5,2) col1 = gtk.TreeViewColumn('Regex', self.cell1) col1.set_cell_data_func(self.cell1, self.regex_field) self.sstatemirrors_tv.append_column(col1) self.cell1.connect("edited", self.regex_changed, sstatemirrors_store) cell2 = gtk.CellRendererText() cell2.set_padding(5,2) cell2.set_property("editable", True) col2 = gtk.TreeViewColumn('URL', cell2) col2.set_cell_data_func(cell2, self.url_field) self.sstatemirrors_tv.append_column(col2) cell2.connect("edited", self.url_changed, sstatemirrors_store) self.sstatemirrors_tv.set_model(sstatemirrors_store) self.sstatemirrors_tv.set_cursor(self.selected_mirror_row) hbox.pack_start(self.scroll, expand=True, fill=True) hbox.show_all() return hbox, sstatemirrors_store def drag_data_get_cb(self, treeview, context, selection, target_id, etime): treeselection = treeview.get_selection() model, iter = treeselection.get_selected() data = model.get_string_from_iter(iter) selection.set(selection.target, 8, data) def drag_data_received_cb(self, treeview, context, x, y, selection, info, etime): model = treeview.get_model() data = [] tree_iter = model.get_iter_from_string(selection.data) data.append(model.get_value(tree_iter, 0)) data.append(model.get_value(tree_iter, 1)) data.append(model.get_value(tree_iter, 2)) drop_info = treeview.get_dest_row_at_pos(x, y) if drop_info: path, position = drop_info iter = model.get_iter(path) if (position == gtk.TREE_VIEW_DROP_BEFORE or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE): model.insert_before(iter, data) else: model.insert_after(iter, data) else: model.append(data) if context.action == gtk.gdk.ACTION_MOVE: context.finish(True, True, etime) return def delete_cb(self, button): selection = self.sstatemirrors_tv.get_selection() tree_model, tree_iter = selection.get_selected() index = int(tree_model.get_string_from_iter(tree_iter)) if index == 0: self.selected_mirror_row = index else: self.selected_mirror_row = index - 1 self.sstatemirrors_list.pop(index) self.refresh_shared_state_page() if not self.sstatemirrors_list: self.delete_button.set_sensitive(False) def add_mirror(self, button): self.new_mirror = True tooltip = "Select the pre-built mirror that will speed your build" index = len(self.sstatemirrors_list) self.selected_mirror_row = index sm_list = ["Standard", "", "file://(.*)"] self.sstatemirrors_list.append(sm_list) self.refresh_shared_state_page() def scroll_changed(self, widget, event, data=None): if self.new_mirror == True: adj = widget.get_vadjustment() adj.set_value(adj.upper - adj.page_size) self.new_mirror = False def combo_changed(self, widget, path, text, model): model[path][0] = text selection = self.sstatemirrors_tv.get_selection() tree_model, tree_iter = selection.get_selected() index = int(tree_model.get_string_from_iter(tree_iter)) self.sstatemirrors_list[index][0] = text def regex_changed(self, cell, path, new_text, user_data): user_data[path][2] = new_text selection = self.sstatemirrors_tv.get_selection() tree_model, tree_iter = selection.get_selected() index = int(tree_model.get_string_from_iter(tree_iter)) self.sstatemirrors_list[index][2] = new_text return def url_changed(self, cell, path, new_text, user_data): if new_text!="Enter the mirror URL" and new_text!="Match regex and replace it with this URL": user_data[path][1] = new_text selection = self.sstatemirrors_tv.get_selection() tree_model, tree_iter = selection.get_selected() index = int(tree_model.get_string_from_iter(tree_iter)) self.sstatemirrors_list[index][1] = new_text return def configuration_field(self, column, cell, model, iter): cell.set_property('text', model.get_value(iter, 0)) if model.get_value(iter, 0) == "Standard": self.cell1.set_property("sensitive", False) self.cell1.set_property("editable", False) else: self.cell1.set_property("sensitive", True) self.cell1.set_property("editable", True) return def regex_field(self, column, cell, model, iter): cell.set_property('text', model.get_value(iter, 2)) return def url_field(self, column, cell, model, iter): text = model.get_value(iter, 1) if text == "": if model.get_value(iter, 0) == "Standard": text = "Enter the mirror URL" else: text = "Match regex and replace it with this URL" cell.set_property('text', text) return def refresh_shared_state_page(self): page_num = self.nb.get_current_page() self.nb.remove_page(page_num); self.nb.insert_page(self.create_shared_state_page(), gtk.Label("Shared state"),page_num) self.show_all() self.nb.set_current_page(page_num) def test_proxy_ended(self, passed): self.proxy_test_running = False self.set_test_proxy_state(self.TEST_NETWORK_PASSED if passed else self.TEST_NETWORK_FAILED) self.set_sensitive(True) self.refresh_proxy_components() def timer_func(self): self.test_proxy_progress.pulse() return self.proxy_test_running def test_network_button_cb(self, b): self.set_test_proxy_state(self.TEST_NETWORK_RUNNING) self.set_sensitive(False) self.save_proxy_data() if self.configuration.enable_proxy == True: self.handler.set_http_proxy(self.configuration.combine_proxy("http")) self.handler.set_https_proxy(self.configuration.combine_proxy("https")) self.handler.set_ftp_proxy(self.configuration.combine_proxy("ftp")) self.handler.set_socks_proxy(self.configuration.combine_proxy("socks")) self.handler.set_cvs_proxy(self.configuration.combine_host_only("cvs"), self.configuration.combine_port_only("cvs")) elif self.configuration.enable_proxy == False: self.handler.set_http_proxy("") self.handler.set_https_proxy("") self.handler.set_ftp_proxy("") self.handler.set_socks_proxy("") self.handler.set_cvs_proxy("", "") self.proxy_test_ran = True self.proxy_test_running = True gobject.timeout_add(100, self.timer_func) self.handler.trigger_network_test() def test_proxy_focus_event(self, w, direction): if self.test_proxy_state in [self.TEST_NETWORK_PASSED, self.TEST_NETWORK_FAILED]: self.set_test_proxy_state(self.TEST_NETWORK_INITIAL) return False def http_proxy_changed(self, e): if not self.configuration.same_proxy: return if e == self.http_proxy: [w.set_text(self.http_proxy.get_text()) for w in self.same_proxy_addresses] else: [w.set_text(self.http_proxy_port.get_text()) for w in self.same_proxy_ports] def proxy_address_focus_out_event(self, w, direction): text = w.get_text() if not text: return False if text.find("//") == -1: w.set_text("http://" + text) return False def set_test_proxy_state(self, state): if self.test_proxy_state == state: return [self.proxy_table.remove(w) for w in self.test_gui_elements] if state == self.TEST_NETWORK_INITIAL: self.proxy_table.attach(self.test_network_button, 1, 2, 5, 6) self.test_network_button.show() elif state == self.TEST_NETWORK_RUNNING: self.test_proxy_progress.set_rcstyle("running") self.test_proxy_progress.set_text("Testing network configuration") self.proxy_table.attach(self.test_proxy_progress, 0, 5, 5, 6, xpadding=4) self.test_proxy_progress.show() else: # passed or failed self.dummy_progress.update(1.0) if state == self.TEST_NETWORK_PASSED: self.dummy_progress.set_text("Your network is properly configured") self.dummy_progress.set_rcstyle("running") else: self.dummy_progress.set_text("Network test failed") self.dummy_progress.set_rcstyle("fail") self.proxy_table.attach(self.dummy_progress, 0, 4, 5, 6) self.proxy_table.attach(self.retest_network_button, 4, 5, 5, 6, xpadding=4) self.dummy_progress.show() self.retest_network_button.show() self.test_proxy_state = state def create_network_page(self): advanced_vbox = gtk.VBox(False, 6) advanced_vbox.set_border_width(6) self.same_proxy_addresses = [] self.same_proxy_ports = [] self.all_proxy_ports = [] self.all_proxy_addresses = [] sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) label = self.gen_label_widget("<span weight=\"bold\">Set the proxies used when fetching source code</span>") tooltip = "Set the proxies used when fetching source code. A blank field uses a direct internet connection." info = HobInfoButton("<span weight=\"bold\">Set the proxies used when fetching source code</span>" + "*" + tooltip, self) hbox = gtk.HBox(False, 12) hbox.pack_start(label, expand=True, fill=True) hbox.pack_start(info, expand=False, fill=False) sub_vbox.pack_start(hbox, expand=False, fill=False) proxy_test_focus = [] self.direct_checkbox = gtk.RadioButton(None, "Direct network connection") proxy_test_focus.append(self.direct_checkbox) self.direct_checkbox.set_tooltip_text("Check this box to use a direct internet connection with no proxy") self.direct_checkbox.set_active(not self.configuration.enable_proxy) sub_vbox.pack_start(self.direct_checkbox, expand=False, fill=False) self.proxy_checkbox = gtk.RadioButton(self.direct_checkbox, "Manual proxy configuration") proxy_test_focus.append(self.proxy_checkbox) self.proxy_checkbox.set_tooltip_text("Check this box to manually set up a specific proxy") self.proxy_checkbox.set_active(self.configuration.enable_proxy) sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) self.same_checkbox = gtk.CheckButton("Use the HTTP proxy for all protocols") proxy_test_focus.append(self.same_checkbox) self.same_checkbox.set_tooltip_text("Check this box to use the HTTP proxy for all five proxies") self.same_checkbox.set_active(self.configuration.same_proxy) hbox = gtk.HBox(False, 12) hbox.pack_start(self.same_checkbox, expand=False, fill=False, padding=24) sub_vbox.pack_start(hbox, expand=False, fill=False) self.proxy_table = gtk.Table(6, 5, False) self.http_proxy, self.http_proxy_port, self.http_proxy_details = self.gen_proxy_entry_widget( "http", self, True, 0) proxy_test_focus +=[self.http_proxy, self.http_proxy_port] self.http_proxy.connect("changed", self.http_proxy_changed) self.http_proxy_port.connect("changed", self.http_proxy_changed) self.https_proxy, self.https_proxy_port, self.https_proxy_details = self.gen_proxy_entry_widget( "https", self, True, 1) proxy_test_focus += [self.https_proxy, self.https_proxy_port] self.same_proxy_addresses.append(self.https_proxy) self.same_proxy_ports.append(self.https_proxy_port) self.ftp_proxy, self.ftp_proxy_port, self.ftp_proxy_details = self.gen_proxy_entry_widget( "ftp", self, True, 2) proxy_test_focus += [self.ftp_proxy, self.ftp_proxy_port] self.same_proxy_addresses.append(self.ftp_proxy) self.same_proxy_ports.append(self.ftp_proxy_port) self.socks_proxy, self.socks_proxy_port, self.socks_proxy_details = self.gen_proxy_entry_widget( "socks", self, True, 3) proxy_test_focus += [self.socks_proxy, self.socks_proxy_port] self.same_proxy_addresses.append(self.socks_proxy) self.same_proxy_ports.append(self.socks_proxy_port) self.cvs_proxy, self.cvs_proxy_port, self.cvs_proxy_details = self.gen_proxy_entry_widget( "cvs", self, True, 4) proxy_test_focus += [self.cvs_proxy, self.cvs_proxy_port] self.same_proxy_addresses.append(self.cvs_proxy) self.same_proxy_ports.append(self.cvs_proxy_port) self.all_proxy_ports = self.same_proxy_ports + [self.http_proxy_port] self.all_proxy_addresses = self.same_proxy_addresses + [self.http_proxy] sub_vbox.pack_start(self.proxy_table, expand=False, fill=False) self.proxy_table.show_all() # Create the graphical elements for the network test feature, but don't display them yet self.test_network_button = HobAltButton("Test network configuration") self.test_network_button.connect("clicked", self.test_network_button_cb) self.test_proxy_progress = HobProgressBar() self.dummy_progress = HobProgressBar() self.retest_network_button = HobAltButton("Retest") self.retest_network_button.connect("clicked", self.test_network_button_cb) self.test_gui_elements = [self.test_network_button, self.test_proxy_progress, self.dummy_progress, self.retest_network_button] # Initialize the network tester self.test_proxy_state = self.TEST_NETWORK_NONE self.set_test_proxy_state(self.TEST_NETWORK_INITIAL) self.proxy_test_passed_id = self.handler.connect("network-passed", lambda h:self.test_proxy_ended(True)) self.proxy_test_failed_id = self.handler.connect("network-failed", lambda h:self.test_proxy_ended(False)) [w.connect("focus-in-event", self.test_proxy_focus_event) for w in proxy_test_focus] [w.connect("focus-out-event", self.proxy_address_focus_out_event) for w in self.all_proxy_addresses] self.direct_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) self.same_checkbox.connect("toggled", self.same_checkbox_toggled_cb) self.refresh_proxy_components() return advanced_vbox def switch_to_page(self, page_id): self.nb.set_current_page(page_id) def details_cb(self, button, parent, protocol): self.save_proxy_data() dialog = ProxyDetailsDialog(title = protocol.upper() + " Proxy Details", user = self.configuration.proxies[protocol][1], passwd = self.configuration.proxies[protocol][2], parent = parent, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR) dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_OK) response = dialog.run() if response == gtk.RESPONSE_OK: self.configuration.proxies[protocol][1] = dialog.user self.configuration.proxies[protocol][2] = dialog.passwd self.refresh_proxy_components() dialog.destroy() def rootfs_combo_changed_cb(self, rootfs_combo, all_package_format, check_hbox): combo_item = self.rootfs_combo.get_active_text() for child in check_hbox.get_children(): if isinstance(child, gtk.CheckButton): check_hbox.remove(child) for format in all_package_format: if format != combo_item: check_button = gtk.CheckButton(format) check_hbox.pack_start(check_button, expand=False, fill=False) check_hbox.show_all() def gen_pkgfmt_widget(self, curr_package_format, all_package_format, tooltip_combo="", tooltip_extra=""): pkgfmt_hbox = gtk.HBox(False, 24) rootfs_vbox = gtk.VBox(False, 6) pkgfmt_hbox.pack_start(rootfs_vbox, expand=False, fill=False) label = self.gen_label_widget("Root file system package format") rootfs_vbox.pack_start(label, expand=False, fill=False) rootfs_format = "" if curr_package_format: rootfs_format = curr_package_format.split()[0] rootfs_format_widget, rootfs_combo = self.gen_combo_widget(rootfs_format, all_package_format, tooltip_combo) rootfs_vbox.pack_start(rootfs_format_widget, expand=False, fill=False) extra_vbox = gtk.VBox(False, 6) pkgfmt_hbox.pack_start(extra_vbox, expand=False, fill=False) label = self.gen_label_widget("Additional package formats") extra_vbox.pack_start(label, expand=False, fill=False) check_hbox = gtk.HBox(False, 12) extra_vbox.pack_start(check_hbox, expand=False, fill=False) for format in all_package_format: if format != rootfs_format: check_button = gtk.CheckButton(format) is_active = (format in curr_package_format.split()) check_button.set_active(is_active) check_hbox.pack_start(check_button, expand=False, fill=False) info = HobInfoButton(tooltip_extra, self) check_hbox.pack_end(info, expand=False, fill=False) rootfs_combo.connect("changed", self.rootfs_combo_changed_cb, all_package_format, check_hbox) pkgfmt_hbox.show_all() return pkgfmt_hbox, rootfs_combo, check_hbox def editable_settings_cell_edited(self, cell, path_string, new_text, model): it = model.get_iter_from_string(path_string) column = cell.get_data("column") model.set(it, column, new_text) def editable_settings_add_item_clicked(self, button, model): new_item = ["##KEY##", "##VALUE##"] iter = model.append() model.set (iter, 0, new_item[0], 1, new_item[1], ) def editable_settings_remove_item_clicked(self, button, treeview): selection = treeview.get_selection() model, iter = selection.get_selected() if iter: path = model.get_path(iter)[0] model.remove(iter) def gen_editable_settings(self, setting, tooltip=""): setting_hbox = gtk.HBox(False, 12) vbox = gtk.VBox(False, 12) setting_hbox.pack_start(vbox, expand=True, fill=True) setting_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) for key in setting.keys(): setting_store.set(setting_store.append(), 0, key, 1, setting[key]) setting_tree = gtk.TreeView(setting_store) setting_tree.set_headers_visible(True) setting_tree.set_size_request(300, 100) col = gtk.TreeViewColumn('Key') col.set_min_width(100) col.set_max_width(150) col.set_resizable(True) col1 = gtk.TreeViewColumn('Value') col1.set_min_width(100) col1.set_max_width(150) col1.set_resizable(True) setting_tree.append_column(col) setting_tree.append_column(col1) cell = gtk.CellRendererText() cell.set_property('width-chars', 10) cell.set_property('editable', True) cell.set_data("column", 0) cell.connect("edited", self.editable_settings_cell_edited, setting_store) cell1 = gtk.CellRendererText() cell1.set_property('width-chars', 10) cell1.set_property('editable', True) cell1.set_data("column", 1) cell1.connect("edited", self.editable_settings_cell_edited, setting_store) col.pack_start(cell, True) col1.pack_end(cell1, True) col.set_attributes(cell, text=0) col1.set_attributes(cell1, text=1) scroll = gtk.ScrolledWindow() scroll.set_shadow_type(gtk.SHADOW_IN) scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(setting_tree) vbox.pack_start(scroll, expand=True, fill=True) # some buttons hbox = gtk.HBox(True, 6) vbox.pack_start(hbox, False, False) button = gtk.Button(stock=gtk.STOCK_ADD) button.connect("clicked", self.editable_settings_add_item_clicked, setting_store) hbox.pack_start(button) button = gtk.Button(stock=gtk.STOCK_REMOVE) button.connect("clicked", self.editable_settings_remove_item_clicked, setting_tree) hbox.pack_start(button) info = HobInfoButton(tooltip, self) setting_hbox.pack_start(info, expand=False, fill=False) return setting_hbox, setting_store def create_others_page(self): advanced_vbox = gtk.VBox(False, 6) advanced_vbox.set_border_width(6) sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=True, fill=True) label = self.gen_label_widget("<span weight=\"bold\">Add your own variables:</span>") tooltip = "These are key/value pairs for your extra settings. Click \'Add\' and then directly edit the key and the value" setting_widget, self.setting_store = self.gen_editable_settings(self.configuration.extra_setting,"<b>Add your own variables</b>" + "*" + tooltip) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(setting_widget, expand=True, fill=True) return advanced_vbox def create_visual_elements(self): self.nb = gtk.Notebook() self.nb.set_show_tabs(True) self.nb.append_page(self.create_build_environment_page(), gtk.Label("Build environment")) self.nb.append_page(self.create_shared_state_page(), gtk.Label("Shared state")) self.nb.append_page(self.create_network_page(), gtk.Label("Network")) self.nb.append_page(self.create_others_page(), gtk.Label("Others")) self.nb.set_current_page(0) self.vbox.pack_start(self.nb, expand=True, fill=True) self.vbox.pack_end(gtk.HSeparator(), expand=True, fill=True) self.show_all() def destroy(self): self.handler.disconnect(self.proxy_test_passed_id) self.handler.disconnect(self.proxy_test_failed_id) super(SimpleSettingsDialog, self).destroy()
class BuildDetailsPage(HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0, ) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.task_status = gtk.Label("\n") # to ensure layout is correct self.task_status.set_alignment(0.0, 0.5) self.progress_box.pack_start(self.task_status, expand=False, fill=False) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) self.stop_button.set_sensitive(False) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.notebook = HobNotebook() self.config_tv = BuildConfigurationTreeView() self.scrolled_view_config = gtk.ScrolledWindow() self.scrolled_view_config.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_config.add(self.config_tv) self.notebook.append_page(self.scrolled_view_config, "Build configuration") self.failure_tv = BuildFailureTreeView() self.failure_model = self.builder.handler.build.model.failure_model() self.failure_tv.set_model(self.failure_model) self.scrolled_view_failure = gtk.ScrolledWindow() self.scrolled_view_failure.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_failure.add(self.failure_tv) self.notebook.append_page(self.scrolled_view_failure, "Issues") self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow() self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.notebook.append_page(self.scrolled_view_build, "Log") self.builder.handler.build.model.connect_after( "row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton('<< Back') self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def update_build_status(self, current, total, task): recipe_path, recipe_task = task.split(", ") recipe = os.path.basename(recipe_path).rstrip(".bb") tsk_msg = "<b>Running task %s of %s:</b> %s\n<b>Recipe:</b> %s" % ( current, total, recipe_task, recipe) self.task_status.set_markup(tsk_msg) self.stop_button.set_sensitive(True) def reset_build_status(self): self.task_status.set_markup("\n") # to ensure layout is correct self.endpath = (0, ) def show_issues(self): self.num_of_issues += 1 self.notebook.show_indicator_icon("Issues", self.num_of_issues) def reset_issues(self): self.num_of_issues = 0 self.notebook.hide_indicator_icon("Issues") def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def add_build_fail_top_bar(self, actions, log_file=None): primary_action = "Edit %s" % actions self.notebook.set_page("Issues") color = HobColors.ERROR build_fail_top = gtk.EventBox() build_fail_top.set_size_request(-1, 200) build_fail_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_fail_tab = gtk.Table(14, 46, True) build_fail_top.add(build_fail_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file( hic.ICON_INDI_ERROR_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_fail_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_fail_tab.attach(label, 4, 26, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup( "<span size='medium'>Check the \"Issues\" information for more details</span>" ) build_fail_tab.attach(label, 4, 40, 4, 9) # create button 'Edit packages' action_button = HobButton(primary_action) action_button.set_size_request(-1, 40) action_button.set_tooltip_text("Edit the %s parameters" % actions) action_button.connect('clicked', self.failure_primary_action_button_clicked_cb, primary_action) build_fail_tab.attach(action_button, 4, 13, 9, 12) if log_file: open_log_button = HobAltButton("Open log") open_log_button.set_relief(gtk.RELIEF_HALF) open_log_button.set_tooltip_text("Open the build's log file") open_log_button.connect('clicked', self.failure_open_log_button_clicked_cb, log_file) build_fail_tab.attach(open_log_button, 14, 23, 9, 12) attach_pos = (24 if log_file else 14) file_bug_button = HobAltButton('File a bug') file_bug_button.set_relief(gtk.RELIEF_HALF) file_bug_button.set_tooltip_text( "Open the Yocto Project bug tracking website") file_bug_button.connect('clicked', self.failure_activate_file_bug_link_cb) build_fail_tab.attach(file_bug_button, attach_pos, attach_pos + 9, 9, 12) return build_fail_top def show_fail_page(self, title, action_names): self._remove_all_widget() self.title = "Hob cannot build your %s" % title self.build_fail_bar = self.add_build_fail_top_bar( action_names, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_fail_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.config_tv.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() self.reset_build_status() self.reset_issues() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[ 0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def show_configurations(self, configurations, params): self.config_tv.show(configurations, params) def failure_primary_action_button_clicked_cb(self, button, action): if "Edit recipes" in action: self.builder.show_recipes() elif "Edit packages" in action: self.builder.show_packages() elif "Edit image configuration" in action: self.builder.show_configuration() def failure_open_log_button_clicked_cb(self, button, log_file): if log_file: os.system("xdg-open /%s" % log_file) def failure_activate_file_bug_link_cb(self, button): button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")
def create_bottom_buttons(self, buttonlist, image_name): # Create the buttons at the bottom created = False packed = False self.button_ids = {} is_runnable = False # create button "Deploy image" name = "Deploy image" if name in buttonlist and self.test_deployable(image_name): deploy_button = HobButton('Deploy image') #deploy_button.set_size_request(205, 49) deploy_button.set_tooltip_text("Burn a live image to a USB drive or flash memory") deploy_button.set_flags(gtk.CAN_DEFAULT) button_id = deploy_button.connect("clicked", self.deploy_button_clicked_cb) self.button_ids[button_id] = deploy_button self.details_bottom_buttons.pack_end(deploy_button, expand=False, fill=False) created = True packed = True name = "Run image" if name in buttonlist and self.test_type_runnable(image_name) and self.test_mach_runnable(image_name): if created == True: # separator #label = gtk.Label(" or ") #self.details_bottom_buttons.pack_end(label, expand=False, fill=False) # create button "Run image" run_button = HobAltButton("Run image") else: # create button "Run image" as the primary button run_button = HobButton("Run image") #run_button.set_size_request(205, 49) run_button.set_flags(gtk.CAN_DEFAULT) packed = True run_button.set_tooltip_text("Start up an image with qemu emulator") button_id = run_button.connect("clicked", self.run_button_clicked_cb) self.button_ids[button_id] = run_button self.details_bottom_buttons.pack_end(run_button, expand=False, fill=False) created = True is_runnable = True name = "Save image recipe" if name in buttonlist and self.builder.recipe_model.is_custom_image(): save_button = HobAltButton("Save image recipe") save_button.set_tooltip_text("Keep your changes saving them as an image recipe") save_button.set_sensitive(not self.image_saved) button_id = save_button.connect("clicked", self.save_button_clicked_cb) self.button_ids[button_id] = save_button self.details_bottom_buttons.pack_end(save_button, expand=False, fill=False) name = "Build new image" if name in buttonlist: # create button "Build new image" if packed: build_new_button = HobAltButton("Build new image") else: build_new_button = HobButton("Build new image") build_new_button.set_flags(gtk.CAN_DEFAULT) #build_new_button.set_size_request(205, 49) self.details_bottom_buttons.pack_end(build_new_button, expand=False, fill=False) build_new_button.set_tooltip_text("Create a new image from scratch") button_id = build_new_button.connect("clicked", self.build_new_button_clicked_cb) self.button_ids[button_id] = build_new_button return is_runnable
class BuildDetailsPage (HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0,) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) tooltip = "Cancel build in progress" self.stop_button.set_tooltip_text(tooltip) self.stop_button.set_sensitive(True) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow () self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.builder.handler.build.model.connect_after("row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton('<< Back') self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def reset_build_status(self): self.endpath = (0,) def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def add_build_fail_top_bar(self, actions, log_file=None): primary_action = "Edit %s" % actions color = HobColors.ERROR build_fail_top = gtk.EventBox() #build_fail_top.set_size_request(-1, 200) build_fail_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_fail_tab = gtk.Table(14, 46, True) build_fail_top.add(build_fail_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ERROR_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_fail_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_fail_tab.attach(label, 4, 40, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) # Ensure variable disk_full is defined if not hasattr(self.builder, 'disk_full'): self.builder.disk_full = False if self.builder.disk_full: markup = "<span size='medium'>There is no disk space left, so Hob cannot finish building your image. Free up some disk space\n" markup += "and restart the build." label.set_markup(markup) build_fail_tab.attach(label, 4, 40, 4, 9) # create button 'Edit packages' action_button = HobButton(primary_action) #action_button.set_size_request(-1, 40) action_button.set_tooltip_text("Edit the %s parameters" % actions) action_button.connect('clicked', self.failure_primary_action_button_clicked_cb, primary_action) if not self.builder.disk_full: build_fail_tab.attach(action_button, 4, 19, 9, 12) else: restart_build = HobButton("Restart the build") restart_build.set_tooltip_text("Restart the build") restart_build.connect('clicked', self.restart_build_button_clicked_cb) build_fail_tab.attach(restart_build, 4, 13, 9, 12) build_fail_tab.attach(action_button, 14, 23, 9, 12) self.builder.disk_full = False return build_fail_top def show_fail_page(self, title): self._remove_all_widget() self.title = "Hob cannot build your %s" % title self.build_fail_bar = self.add_build_fail_top_bar(title, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_fail_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.scrolled_view_build, expand=True, fill=True) self.show_all() self.back_button.hide() def add_build_stop_top_bar(self, action, log_file=None): color = HobColors.LIGHT_GRAY build_stop_top = gtk.EventBox() build_stop_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_stop_top.set_flags(gtk.CAN_DEFAULT) build_stop_top.grab_default() build_stop_tab = gtk.Table(11, 46, True) build_stop_top.add(build_stop_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INFO_HOVER_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_stop_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_stop_tab.attach(label, 4, 40, 0, 6) action_button = HobButton("Edit %s" % action) action_button.set_size_request(-1, 40) if action == "image": action_button.set_tooltip_text("Edit the image parameters") elif action == "recipes": action_button.set_tooltip_text("Edit the included recipes") elif action == "packages": action_button.set_tooltip_text("Edit the included packages") action_button.connect('clicked', self.stop_primary_action_button_clicked_cb, action) build_stop_tab.attach(action_button, 4, 20, 6, 9) build_button = HobAltButton("Build new image") build_button.set_tooltip_text("Create a new image from scratch") build_button.connect('clicked', self.new_image_button_clicked_cb) build_stop_tab.attach(build_button, 21, 40, 6, 9) return build_stop_top, action_button def show_stop_page(self, action): self._remove_all_widget() self.title = "Build stopped" self.build_stop_bar, action_button = self.add_build_stop_top_bar(action, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_stop_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.scrolled_view_build, expand=True, fill=True) self.show_all() self.back_button.hide() return action_button def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None, padding=15) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.scrolled_view_build, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() self.reset_build_status() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def new_image_button_clicked_cb(self, button): self.builder.populate_recipe_package_info_async() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def failure_primary_action_button_clicked_cb(self, button, action): if "Edit recipes" in action: self.builder.show_recipes() elif "Edit packages" in action: self.builder.show_packages(ask=False) elif "Edit image" in action: self.builder.show_configuration() def restart_build_button_clicked_cb(self, button): self.builder.just_bake() def stop_primary_action_button_clicked_cb(self, button, action): if "recipes" in action: self.builder.show_recipes() elif "packages" in action: self.builder.show_packages(ask=False) elif "image" in action: self.builder.show_configuration() def open_log_button_clicked_cb(self, button, log_file): if log_file: log_file = "file:///" + log_file gtk.show_uri(screen=button.get_screen(), uri=log_file, timestamp=0) def failure_activate_file_bug_link_cb(self, button): button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")
def gen_mirror_entry_widget(self, content, index, match_content=""): hbox = gtk.HBox(False) entry = gtk.Entry() content = content[:-2] entry.set_text(content) entry.set_size_request(350, 30) entry_match = gtk.Entry() entry_match.set_text(match_content) entry_match.set_size_request(100, 30) table = gtk.Table(2, 5, False) table.set_row_spacings(12) table.set_col_spacings(6) hbox.pack_start(table, expand=True, fill=True) label_configuration = gtk.Label("Configuration") label_configuration.set_alignment(0.0, 0.5) label_mirror_url = gtk.Label("Mirror URL") label_mirror_url.set_alignment(0.0, 0.5) label_match = gtk.Label("Match") label_match.set_alignment(0.0, 0.5) label_replace_with = gtk.Label("Replace with") label_replace_with.set_alignment(0.0, 0.5) combo = gtk.combo_box_new_text() combo.append_text("Standard") combo.append_text("Custom") if match_content == "": combo.set_active(0) else: combo.set_active(1) combo.connect("changed", self.on_combo_changed, index) combo.set_size_request(100, 30) delete_button = HobAltButton("Delete") delete_button.connect("clicked", self.delete_cb, index, entry) if content == "" and index == 0 and len(self.sstatemirrors_list) == 1: delete_button.set_sensitive(False) delete_button.set_size_request(100, 30) entry_match.connect("changed", self.insert_entry_match_cb, index) entry.connect("changed", self.insert_entry_cb, index, delete_button) if match_content == "": table.attach(label_configuration, 1, 2, 0, 1, xoptions=gtk.SHRINK | gtk.FILL) table.attach(label_mirror_url, 2, 3, 0, 1, xoptions=gtk.SHRINK | gtk.FILL) table.attach(combo, 1, 2, 1, 2, xoptions=gtk.SHRINK) table.attach(entry, 2, 3, 1, 2, xoptions=gtk.SHRINK) table.attach(delete_button, 3, 4, 1, 2, xoptions=gtk.SHRINK) else: table.attach(label_configuration, 1, 2, 0, 1, xoptions=gtk.SHRINK | gtk.FILL) table.attach(label_match, 2, 3, 0, 1, xoptions=gtk.SHRINK | gtk.FILL) table.attach(label_replace_with, 3, 4, 0, 1, xoptions=gtk.SHRINK | gtk.FILL) table.attach(combo, 1, 2, 1, 2, xoptions=gtk.SHRINK) table.attach(entry_match, 2, 3, 1, 2, xoptions=gtk.SHRINK) table.attach(entry, 3, 4, 1, 2, xoptions=gtk.SHRINK) table.attach(delete_button, 4, 5, 1, 2, xoptions=gtk.SHRINK) hbox.show_all() return hbox
def gen_mirror_entry_widget(self, content, index, match_content=""): hbox = gtk.HBox(False) entry = gtk.Entry() content = content[:-2] entry.set_text(content) entry.set_size_request(350,30) entry_match = gtk.Entry() entry_match.set_text(match_content) entry_match.set_size_request(100,30) table = gtk.Table(2, 5, False) table.set_row_spacings(12) table.set_col_spacings(6) hbox.pack_start(table, expand=True, fill=True) label_configuration = gtk.Label("Configuration") label_configuration.set_alignment(0.0,0.5) label_mirror_url = gtk.Label("Mirror URL") label_mirror_url.set_alignment(0.0,0.5) label_match = gtk.Label("Match") label_match.set_alignment(0.0,0.5) label_replace_with = gtk.Label("Replace with") label_replace_with.set_alignment(0.0,0.5) combo = gtk.combo_box_new_text() combo.append_text("Standard") combo.append_text("Custom") if match_content == "": combo.set_active(0) else: combo.set_active(1) combo.connect("changed", self.on_combo_changed, index) combo.set_size_request(100,30) delete_button = HobAltButton("Delete") delete_button.connect("clicked", self.delete_cb, index, entry) if content == "" and index == 0 and len(self.sstatemirrors_list) == 1: delete_button.set_sensitive(False) delete_button.set_size_request(100, 30) entry_match.connect("changed", self.insert_entry_match_cb, index) entry.connect("changed", self.insert_entry_cb, index, delete_button) if match_content == "": table.attach(label_configuration, 1, 2, 0, 1, xoptions=gtk.SHRINK|gtk.FILL) table.attach(label_mirror_url, 2, 3, 0, 1, xoptions=gtk.SHRINK|gtk.FILL) table.attach(combo, 1, 2, 1, 2, xoptions=gtk.SHRINK) table.attach(entry, 2, 3, 1, 2, xoptions=gtk.SHRINK) table.attach(delete_button, 3, 4, 1, 2, xoptions=gtk.SHRINK) else: table.attach(label_configuration, 1, 2, 0, 1, xoptions=gtk.SHRINK|gtk.FILL) table.attach(label_match, 2, 3, 0, 1, xoptions=gtk.SHRINK|gtk.FILL) table.attach(label_replace_with, 3, 4, 0, 1, xoptions=gtk.SHRINK|gtk.FILL) table.attach(combo, 1, 2, 1, 2, xoptions=gtk.SHRINK) table.attach(entry_match, 2, 3, 1, 2, xoptions=gtk.SHRINK) table.attach(entry, 3, 4, 1, 2, xoptions=gtk.SHRINK) table.attach(delete_button, 4, 5, 1, 2, xoptions=gtk.SHRINK) hbox.show_all() return hbox
class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): (BUILD_ENV_PAGE_ID, SHARED_STATE_PAGE_ID, PROXIES_PAGE_ID, OTHERS_PAGE_ID) = range(4) (TEST_NETWORK_NONE, TEST_NETWORK_INITIAL, TEST_NETWORK_RUNNING, TEST_NETWORK_PASSED, TEST_NETWORK_FAILED, TEST_NETWORK_CANCELED) = range(6) TARGETS = [ ("MY_TREE_MODEL_ROW", gtk.TARGET_SAME_WIDGET, 0), ("text/plain", 0, 1), ("TEXT", 0, 2), ("STRING", 0, 3), ] def __init__(self, title, configuration, all_image_types, all_package_formats, all_distros, all_sdk_machines, max_threads, parent, flags, handler, buttons=None): super(SimpleSettingsDialog, self).__init__(title, parent, flags, buttons) # class members from other objects # bitbake settings from Builder.Configuration self.configuration = configuration self.image_types = all_image_types self.all_package_formats = all_package_formats self.all_distros = all_distros self.all_sdk_machines = all_sdk_machines self.max_threads = max_threads # class members for internal use self.dldir_text = None self.sstatedir_text = None self.sstatemirrors_list = [] self.sstatemirrors_changed = 0 self.bb_spinner = None self.pmake_spinner = None self.rootfs_size_spinner = None self.extra_size_spinner = None self.gplv3_checkbox = None self.toolchain_checkbox = None self.setting_store = None self.image_types_checkbuttons = {} self.md5 = self.config_md5() self.proxy_md5 = self.config_proxy_md5() self.settings_changed = False self.proxy_settings_changed = False self.handler = handler self.proxy_test_ran = False self.selected_mirror_row = 0 self.new_mirror = False # create visual elements on the dialog self.create_visual_elements() self.connect("response", self.response_cb) def _get_sorted_value(self, var): return " ".join(sorted(str(var).split())) + "\n" def config_proxy_md5(self): data = ("ENABLE_PROXY: " + self._get_sorted_value(self.configuration.enable_proxy)) if self.configuration.enable_proxy: for protocol in self.configuration.proxies.keys(): data += (protocol + ": " + self._get_sorted_value(self.configuration.combine_proxy(protocol))) return hashlib.md5(data).hexdigest() def config_md5(self): data = "" for key in self.configuration.extra_setting.keys(): data += (key + ": " + self._get_sorted_value(self.configuration.extra_setting[key])) return hashlib.md5(data).hexdigest() def gen_proxy_entry_widget(self, protocol, parent, need_button=True, line=0): label = gtk.Label(protocol.upper() + " proxy") self.proxy_table.attach(label, 0, 1, line, line+1, xpadding=24) proxy_entry = gtk.Entry() proxy_entry.set_size_request(300, -1) self.proxy_table.attach(proxy_entry, 1, 2, line, line+1, ypadding=4) self.proxy_table.attach(gtk.Label(":"), 2, 3, line, line+1, xpadding=12, ypadding=4) port_entry = gtk.Entry() port_entry.set_size_request(60, -1) self.proxy_table.attach(port_entry, 3, 4, line, line+1, ypadding=4) details_button = HobAltButton("Details") details_button.connect("clicked", self.details_cb, parent, protocol) self.proxy_table.attach(details_button, 4, 5, line, line+1, xpadding=4, yoptions=gtk.EXPAND) return proxy_entry, port_entry, details_button def refresh_proxy_components(self): self.same_checkbox.set_sensitive(self.configuration.enable_proxy) self.http_proxy.set_text(self.configuration.combine_host_only("http")) self.http_proxy.set_editable(self.configuration.enable_proxy) self.http_proxy.set_sensitive(self.configuration.enable_proxy) self.http_proxy_port.set_text(self.configuration.combine_port_only("http")) self.http_proxy_port.set_editable(self.configuration.enable_proxy) self.http_proxy_port.set_sensitive(self.configuration.enable_proxy) self.http_proxy_details.set_sensitive(self.configuration.enable_proxy) self.https_proxy.set_text(self.configuration.combine_host_only("https")) self.https_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.https_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.https_proxy_port.set_text(self.configuration.combine_port_only("https")) self.https_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.https_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.https_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy.set_text(self.configuration.combine_host_only("ftp")) self.ftp_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy_port.set_text(self.configuration.combine_port_only("ftp")) self.ftp_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.ftp_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy.set_text(self.configuration.combine_host_only("socks")) self.socks_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy_port.set_text(self.configuration.combine_port_only("socks")) self.socks_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.socks_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy.set_text(self.configuration.combine_host_only("cvs")) self.cvs_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy_port.set_text(self.configuration.combine_port_only("cvs")) self.cvs_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) self.cvs_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) if self.configuration.same_proxy: if self.http_proxy.get_text(): [w.set_text(self.http_proxy.get_text()) for w in self.same_proxy_addresses] if self.http_proxy_port.get_text(): [w.set_text(self.http_proxy_port.get_text()) for w in self.same_proxy_ports] def proxy_checkbox_toggled_cb(self, button): self.configuration.enable_proxy = self.proxy_checkbox.get_active() if not self.configuration.enable_proxy: self.configuration.same_proxy = False self.same_checkbox.set_active(self.configuration.same_proxy) self.save_proxy_data() self.refresh_proxy_components() def same_checkbox_toggled_cb(self, button): self.configuration.same_proxy = self.same_checkbox.get_active() self.save_proxy_data() self.refresh_proxy_components() def save_proxy_data(self): self.configuration.split_proxy("http", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) if self.configuration.same_proxy: self.configuration.split_proxy("https", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) self.configuration.split_proxy("ftp", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) self.configuration.split_proxy("socks", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) self.configuration.split_proxy("cvs", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) else: self.configuration.split_proxy("https", self.https_proxy.get_text() + ":" + self.https_proxy_port.get_text()) self.configuration.split_proxy("ftp", self.ftp_proxy.get_text() + ":" + self.ftp_proxy_port.get_text()) self.configuration.split_proxy("socks", self.socks_proxy.get_text() + ":" + self.socks_proxy_port.get_text()) self.configuration.split_proxy("cvs", self.cvs_proxy.get_text() + ":" + self.cvs_proxy_port.get_text()) def response_cb(self, dialog, response_id): if response_id == gtk.RESPONSE_YES: # Check that all proxy entries have a corresponding port for proxy, port in zip(self.all_proxy_addresses, self.all_proxy_ports): if proxy.get_text() and not port.get_text(): lbl = "<b>Enter all port numbers</b>\n\n" msg = "Proxy servers require a port number. Please make sure you have entered a port number for each proxy server." dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING, msg) button = dialog.add_button("Close", gtk.RESPONSE_OK) HobButton.style_button(button) response = dialog.run() dialog.destroy() self.emit_stop_by_name("response") return self.configuration.dldir = self.dldir_text.get_text() self.configuration.sstatedir = self.sstatedir_text.get_text() self.configuration.sstatemirror = "" for mirror in self.sstatemirrors_list: if mirror[1] != "" and mirror[2].startswith("file://"): if mirror[1].endswith("\\1"): smirror = mirror[2] + " " + mirror[1] + " \\n " else: smirror = mirror[2] + " " + mirror[1] + "\\1 \\n " self.configuration.sstatemirror += smirror self.configuration.bbthread = self.bb_spinner.get_value_as_int() self.configuration.pmake = self.pmake_spinner.get_value_as_int() self.save_proxy_data() self.configuration.extra_setting = {} it = self.setting_store.get_iter_first() while it: key = self.setting_store.get_value(it, 0) value = self.setting_store.get_value(it, 1) self.configuration.extra_setting[key] = value it = self.setting_store.iter_next(it) md5 = self.config_md5() self.settings_changed = (self.md5 != md5) self.proxy_settings_changed = (self.proxy_md5 != self.config_proxy_md5()) def create_build_environment_page(self): advanced_vbox = gtk.VBox(False, 6) advanced_vbox.set_border_width(6) advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Parallel threads</span>'), expand=False, fill=False) sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) label = self.gen_label_widget("BitBake parallel threads") tooltip = "Sets the number of threads that BitBake tasks can simultaneously run. See the <a href=\"" tooltip += "http://www.yoctoproject.org/docs/current/poky-ref-manual/" tooltip += "poky-ref-manual.html#var-BB_NUMBER_THREADS\">Poky reference manual</a> for information" bbthread_widget, self.bb_spinner = self.gen_spinner_widget(self.configuration.bbthread, 1, self.max_threads,"<b>BitBake prallalel threads</b>" + "*" + tooltip) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(bbthread_widget, expand=False, fill=False) sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) label = self.gen_label_widget("Make parallel threads") tooltip = "Sets the maximum number of threads the host can use during the build. See the <a href=\"" tooltip += "http://www.yoctoproject.org/docs/current/poky-ref-manual/" tooltip += "poky-ref-manual.html#var-PARALLEL_MAKE\">Poky reference manual</a> for information" pmake_widget, self.pmake_spinner = self.gen_spinner_widget(self.configuration.pmake, 1, self.max_threads,"<b>Make parallel threads</b>" + "*" + tooltip) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(pmake_widget, expand=False, fill=False) advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Downloaded source code</span>'), expand=False, fill=False) sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) label = self.gen_label_widget("Downloads directory") tooltip = "Select a folder that caches the upstream project source code" dldir_widget, self.dldir_text = self.gen_entry_widget(self.configuration.dldir, self,"<b>Downloaded source code</b>" + "*" + tooltip) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(dldir_widget, expand=False, fill=False) return advanced_vbox def create_shared_state_page(self): advanced_vbox = gtk.VBox(False) advanced_vbox.set_border_width(12) sub_vbox = gtk.VBox(False) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False, padding=24) content = "<span>Shared state directory</span>" tooltip = "Select a folder that caches your prebuilt results" label = self.gen_label_info_widget(content,"<b>Shared state directory</b>" + "*" + tooltip) sstatedir_widget, self.sstatedir_text = self.gen_entry_widget(self.configuration.sstatedir, self) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(sstatedir_widget, expand=False, fill=False, padding=6) content = "<span weight=\"bold\">Shared state mirrors</span>" tooltip = "URLs pointing to pre-built mirrors that will speed your build. " tooltip += "Select the \'Standard\' configuration if the structure of your " tooltip += "mirror replicates the structure of your local shared state directory. " tooltip += "For more information on shared state mirrors, check the <a href=\"" tooltip += "http://www.yoctoproject.org/docs/current/poky-ref-manual/" tooltip += "poky-ref-manual.html#shared-state\">Yocto Project Reference Manual</a>." table = self.gen_label_info_widget(content,"<b>Shared state mirrors</b>" + "*" + tooltip) advanced_vbox.pack_start(table, expand=False, fill=False, padding=6) sub_vbox = gtk.VBox(False) advanced_vbox.pack_start(sub_vbox, gtk.TRUE, gtk.TRUE, 0) searched_string = "file://" if self.sstatemirrors_changed == 0: self.sstatemirrors_changed = 1 sstatemirrors = self.configuration.sstatemirror if sstatemirrors == "": sm_list = ["Standard", "", "file://(.*)"] self.sstatemirrors_list.append(sm_list) else: while sstatemirrors.find(searched_string) != -1: if sstatemirrors.find(searched_string,1) != -1: sstatemirror = sstatemirrors[:sstatemirrors.find(searched_string,1)] sstatemirrors = sstatemirrors[sstatemirrors.find(searched_string,1):] else: sstatemirror = sstatemirrors sstatemirrors = sstatemirrors[1:] sstatemirror_fields = [x for x in sstatemirror.split(' ') if x.strip()] if len(sstatemirror_fields): if sstatemirror_fields[0] == "file://(.*)": sm_list = ["Standard", sstatemirror_fields[1], "file://(.*)"] else: sm_list = ["Custom", sstatemirror_fields[1], sstatemirror_fields[0]] self.sstatemirrors_list.append(sm_list) sstatemirrors_widget, sstatemirrors_store = self.gen_shared_sstate_widget(self.sstatemirrors_list, self) sub_vbox.pack_start(sstatemirrors_widget, expand=True, fill=True) table = gtk.Table(1, 10, False) table.set_col_spacings(6) add_mirror_button = HobAltButton("Add mirror") add_mirror_button.connect("clicked", self.add_mirror) add_mirror_button.set_size_request(120,30) table.attach(add_mirror_button, 1, 2, 0, 1, xoptions=gtk.SHRINK) self.delete_button = HobAltButton("Delete mirror") self.delete_button.connect("clicked", self.delete_cb) self.delete_button.set_size_request(120, 30) table.attach(self.delete_button, 3, 4, 0, 1, xoptions=gtk.SHRINK) advanced_vbox.pack_start(table, expand=False, fill=False, padding=6) return advanced_vbox def gen_shared_sstate_widget(self, sstatemirrors_list, window): hbox = gtk.HBox(False) sstatemirrors_store = gtk.ListStore(str, str, str) for sstatemirror in sstatemirrors_list: sstatemirrors_store.append(sstatemirror) self.sstatemirrors_tv = gtk.TreeView() self.sstatemirrors_tv.set_rules_hint(True) self.sstatemirrors_tv.set_headers_visible(True) tree_selection = self.sstatemirrors_tv.get_selection() tree_selection.set_mode(gtk.SELECTION_SINGLE) # Allow enable drag and drop of rows including row move self.sstatemirrors_tv.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, self.TARGETS, gtk.gdk.ACTION_DEFAULT| gtk.gdk.ACTION_MOVE) self.sstatemirrors_tv.enable_model_drag_dest(self.TARGETS, gtk.gdk.ACTION_DEFAULT) self.sstatemirrors_tv.connect("drag_data_get", self.drag_data_get_cb) self.sstatemirrors_tv.connect("drag_data_received", self.drag_data_received_cb) self.scroll = gtk.ScrolledWindow() self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.scroll.set_shadow_type(gtk.SHADOW_IN) self.scroll.connect('size-allocate', self.scroll_changed) self.scroll.add(self.sstatemirrors_tv) #list store for cell renderer m = gtk.ListStore(gobject.TYPE_STRING) m.append(["Standard"]) m.append(["Custom"]) cell0 = gtk.CellRendererCombo() cell0.set_property("model",m) cell0.set_property("text-column", 0) cell0.set_property("editable", True) cell0.set_property("has-entry", False) col0 = gtk.TreeViewColumn("Configuration") col0.pack_start(cell0, False) col0.add_attribute(cell0, "text", 0) col0.set_cell_data_func(cell0, self.configuration_field) self.sstatemirrors_tv.append_column(col0) cell0.connect("edited", self.combo_changed, sstatemirrors_store) self.cell1 = gtk.CellRendererText() self.cell1.set_padding(5,2) col1 = gtk.TreeViewColumn('Regex', self.cell1) col1.set_cell_data_func(self.cell1, self.regex_field) self.sstatemirrors_tv.append_column(col1) self.cell1.connect("edited", self.regex_changed, sstatemirrors_store) cell2 = gtk.CellRendererText() cell2.set_padding(5,2) cell2.set_property("editable", True) col2 = gtk.TreeViewColumn('URL', cell2) col2.set_cell_data_func(cell2, self.url_field) self.sstatemirrors_tv.append_column(col2) cell2.connect("edited", self.url_changed, sstatemirrors_store) self.sstatemirrors_tv.set_model(sstatemirrors_store) self.sstatemirrors_tv.set_cursor(self.selected_mirror_row) hbox.pack_start(self.scroll, expand=True, fill=True) hbox.show_all() return hbox, sstatemirrors_store def drag_data_get_cb(self, treeview, context, selection, target_id, etime): treeselection = treeview.get_selection() model, iter = treeselection.get_selected() data = model.get_string_from_iter(iter) selection.set(selection.target, 8, data) def drag_data_received_cb(self, treeview, context, x, y, selection, info, etime): model = treeview.get_model() data = [] tree_iter = model.get_iter_from_string(selection.data) data.append(model.get_value(tree_iter, 0)) data.append(model.get_value(tree_iter, 1)) data.append(model.get_value(tree_iter, 2)) drop_info = treeview.get_dest_row_at_pos(x, y) if drop_info: path, position = drop_info iter = model.get_iter(path) if (position == gtk.TREE_VIEW_DROP_BEFORE or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE): model.insert_before(iter, data) else: model.insert_after(iter, data) else: model.append(data) if context.action == gtk.gdk.ACTION_MOVE: context.finish(True, True, etime) return def delete_cb(self, button): selection = self.sstatemirrors_tv.get_selection() tree_model, tree_iter = selection.get_selected() index = int(tree_model.get_string_from_iter(tree_iter)) if index == 0: self.selected_mirror_row = index else: self.selected_mirror_row = index - 1 self.sstatemirrors_list.pop(index) self.refresh_shared_state_page() if not self.sstatemirrors_list: self.delete_button.set_sensitive(False) def add_mirror(self, button): self.new_mirror = True tooltip = "Select the pre-built mirror that will speed your build" index = len(self.sstatemirrors_list) self.selected_mirror_row = index sm_list = ["Standard", "", "file://(.*)"] self.sstatemirrors_list.append(sm_list) self.refresh_shared_state_page() def scroll_changed(self, widget, event, data=None): if self.new_mirror == True: adj = widget.get_vadjustment() adj.set_value(adj.upper - adj.page_size) self.new_mirror = False def combo_changed(self, widget, path, text, model): model[path][0] = text selection = self.sstatemirrors_tv.get_selection() tree_model, tree_iter = selection.get_selected() index = int(tree_model.get_string_from_iter(tree_iter)) self.sstatemirrors_list[index][0] = text def regex_changed(self, cell, path, new_text, user_data): user_data[path][2] = new_text selection = self.sstatemirrors_tv.get_selection() tree_model, tree_iter = selection.get_selected() index = int(tree_model.get_string_from_iter(tree_iter)) self.sstatemirrors_list[index][2] = new_text return def url_changed(self, cell, path, new_text, user_data): if new_text!="Enter the mirror URL" and new_text!="Match regex and replace it with this URL": user_data[path][1] = new_text selection = self.sstatemirrors_tv.get_selection() tree_model, tree_iter = selection.get_selected() index = int(tree_model.get_string_from_iter(tree_iter)) self.sstatemirrors_list[index][1] = new_text return def configuration_field(self, column, cell, model, iter): cell.set_property('text', model.get_value(iter, 0)) if model.get_value(iter, 0) == "Standard": self.cell1.set_property("sensitive", False) self.cell1.set_property("editable", False) else: self.cell1.set_property("sensitive", True) self.cell1.set_property("editable", True) return def regex_field(self, column, cell, model, iter): cell.set_property('text', model.get_value(iter, 2)) return def url_field(self, column, cell, model, iter): text = model.get_value(iter, 1) if text == "": if model.get_value(iter, 0) == "Standard": text = "Enter the mirror URL" else: text = "Match regex and replace it with this URL" cell.set_property('text', text) return def refresh_shared_state_page(self): page_num = self.nb.get_current_page() self.nb.remove_page(page_num); self.nb.insert_page(self.create_shared_state_page(), gtk.Label("Shared state"),page_num) self.show_all() self.nb.set_current_page(page_num) def test_proxy_ended(self, passed): self.proxy_test_running = False self.set_test_proxy_state(self.TEST_NETWORK_PASSED if passed else self.TEST_NETWORK_FAILED) self.set_sensitive(True) self.refresh_proxy_components() def timer_func(self): self.test_proxy_progress.pulse() return self.proxy_test_running def test_network_button_cb(self, b): self.set_test_proxy_state(self.TEST_NETWORK_RUNNING) self.set_sensitive(False) self.save_proxy_data() if self.configuration.enable_proxy == True: self.handler.set_http_proxy(self.configuration.combine_proxy("http")) self.handler.set_https_proxy(self.configuration.combine_proxy("https")) self.handler.set_ftp_proxy(self.configuration.combine_proxy("ftp")) self.handler.set_socks_proxy(self.configuration.combine_proxy("socks")) self.handler.set_cvs_proxy(self.configuration.combine_host_only("cvs"), self.configuration.combine_port_only("cvs")) elif self.configuration.enable_proxy == False: self.handler.set_http_proxy("") self.handler.set_https_proxy("") self.handler.set_ftp_proxy("") self.handler.set_socks_proxy("") self.handler.set_cvs_proxy("", "") self.proxy_test_ran = True self.proxy_test_running = True gobject.timeout_add(100, self.timer_func) self.handler.trigger_network_test() def test_proxy_focus_event(self, w, direction): if self.test_proxy_state in [self.TEST_NETWORK_PASSED, self.TEST_NETWORK_FAILED]: self.set_test_proxy_state(self.TEST_NETWORK_INITIAL) return False def http_proxy_changed(self, e): if not self.configuration.same_proxy: return if e == self.http_proxy: [w.set_text(self.http_proxy.get_text()) for w in self.same_proxy_addresses] else: [w.set_text(self.http_proxy_port.get_text()) for w in self.same_proxy_ports] def proxy_address_focus_out_event(self, w, direction): text = w.get_text() if not text: return False if text.find("//") == -1: w.set_text("http://" + text) return False def set_test_proxy_state(self, state): if self.test_proxy_state == state: return [self.proxy_table.remove(w) for w in self.test_gui_elements] if state == self.TEST_NETWORK_INITIAL: self.proxy_table.attach(self.test_network_button, 1, 2, 5, 6) self.test_network_button.show() elif state == self.TEST_NETWORK_RUNNING: self.test_proxy_progress.set_rcstyle("running") self.test_proxy_progress.set_text("Testing network configuration") self.proxy_table.attach(self.test_proxy_progress, 0, 5, 5, 6, xpadding=4) self.test_proxy_progress.show() else: # passed or failed self.dummy_progress.update(1.0) if state == self.TEST_NETWORK_PASSED: self.dummy_progress.set_text("Your network is properly configured") self.dummy_progress.set_rcstyle("running") else: self.dummy_progress.set_text("Network test failed") self.dummy_progress.set_rcstyle("fail") self.proxy_table.attach(self.dummy_progress, 0, 4, 5, 6) self.proxy_table.attach(self.retest_network_button, 4, 5, 5, 6, xpadding=4) self.dummy_progress.show() self.retest_network_button.show() self.test_proxy_state = state def create_network_page(self): advanced_vbox = gtk.VBox(False, 6) advanced_vbox.set_border_width(6) self.same_proxy_addresses = [] self.same_proxy_ports = [] self.all_proxy_ports = [] self.all_proxy_addresses = [] sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) label = self.gen_label_widget("<span weight=\"bold\">Set the proxies used when fetching source code</span>") tooltip = "Set the proxies used when fetching source code. A blank field uses a direct internet connection." info = HobInfoButton("<span weight=\"bold\">Set the proxies used when fetching source code</span>" + "*" + tooltip, self) hbox = gtk.HBox(False, 12) hbox.pack_start(label, expand=True, fill=True) hbox.pack_start(info, expand=False, fill=False) sub_vbox.pack_start(hbox, expand=False, fill=False) proxy_test_focus = [] self.direct_checkbox = gtk.RadioButton(None, "Direct network connection") proxy_test_focus.append(self.direct_checkbox) self.direct_checkbox.set_tooltip_text("Check this box to use a direct internet connection with no proxy") self.direct_checkbox.set_active(not self.configuration.enable_proxy) sub_vbox.pack_start(self.direct_checkbox, expand=False, fill=False) self.proxy_checkbox = gtk.RadioButton(self.direct_checkbox, "Manual proxy configuration") proxy_test_focus.append(self.proxy_checkbox) self.proxy_checkbox.set_tooltip_text("Check this box to manually set up a specific proxy") self.proxy_checkbox.set_active(self.configuration.enable_proxy) sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) self.same_checkbox = gtk.CheckButton("Use the HTTP proxy for all protocols") proxy_test_focus.append(self.same_checkbox) self.same_checkbox.set_tooltip_text("Check this box to use the HTTP proxy for all five proxies") self.same_checkbox.set_active(self.configuration.same_proxy) hbox = gtk.HBox(False, 12) hbox.pack_start(self.same_checkbox, expand=False, fill=False, padding=24) sub_vbox.pack_start(hbox, expand=False, fill=False) self.proxy_table = gtk.Table(6, 5, False) self.http_proxy, self.http_proxy_port, self.http_proxy_details = self.gen_proxy_entry_widget( "http", self, True, 0) proxy_test_focus +=[self.http_proxy, self.http_proxy_port] self.http_proxy.connect("changed", self.http_proxy_changed) self.http_proxy_port.connect("changed", self.http_proxy_changed) self.https_proxy, self.https_proxy_port, self.https_proxy_details = self.gen_proxy_entry_widget( "https", self, True, 1) proxy_test_focus += [self.https_proxy, self.https_proxy_port] self.same_proxy_addresses.append(self.https_proxy) self.same_proxy_ports.append(self.https_proxy_port) self.ftp_proxy, self.ftp_proxy_port, self.ftp_proxy_details = self.gen_proxy_entry_widget( "ftp", self, True, 2) proxy_test_focus += [self.ftp_proxy, self.ftp_proxy_port] self.same_proxy_addresses.append(self.ftp_proxy) self.same_proxy_ports.append(self.ftp_proxy_port) self.socks_proxy, self.socks_proxy_port, self.socks_proxy_details = self.gen_proxy_entry_widget( "socks", self, True, 3) proxy_test_focus += [self.socks_proxy, self.socks_proxy_port] self.same_proxy_addresses.append(self.socks_proxy) self.same_proxy_ports.append(self.socks_proxy_port) self.cvs_proxy, self.cvs_proxy_port, self.cvs_proxy_details = self.gen_proxy_entry_widget( "cvs", self, True, 4) proxy_test_focus += [self.cvs_proxy, self.cvs_proxy_port] self.same_proxy_addresses.append(self.cvs_proxy) self.same_proxy_ports.append(self.cvs_proxy_port) self.all_proxy_ports = self.same_proxy_ports + [self.http_proxy_port] self.all_proxy_addresses = self.same_proxy_addresses + [self.http_proxy] sub_vbox.pack_start(self.proxy_table, expand=False, fill=False) self.proxy_table.show_all() # Create the graphical elements for the network test feature, but don't display them yet self.test_network_button = HobAltButton("Test network configuration") self.test_network_button.connect("clicked", self.test_network_button_cb) self.test_proxy_progress = HobProgressBar() self.dummy_progress = HobProgressBar() self.retest_network_button = HobAltButton("Retest") self.retest_network_button.connect("clicked", self.test_network_button_cb) self.test_gui_elements = [self.test_network_button, self.test_proxy_progress, self.dummy_progress, self.retest_network_button] # Initialize the network tester self.test_proxy_state = self.TEST_NETWORK_NONE self.set_test_proxy_state(self.TEST_NETWORK_INITIAL) self.proxy_test_passed_id = self.handler.connect("network-passed", lambda h:self.test_proxy_ended(True)) self.proxy_test_failed_id = self.handler.connect("network-failed", lambda h:self.test_proxy_ended(False)) [w.connect("focus-in-event", self.test_proxy_focus_event) for w in proxy_test_focus] [w.connect("focus-out-event", self.proxy_address_focus_out_event) for w in self.all_proxy_addresses] self.direct_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) self.same_checkbox.connect("toggled", self.same_checkbox_toggled_cb) self.refresh_proxy_components() return advanced_vbox def switch_to_page(self, page_id): self.nb.set_current_page(page_id) def details_cb(self, button, parent, protocol): self.save_proxy_data() dialog = ProxyDetailsDialog(title = protocol.upper() + " Proxy Details", user = self.configuration.proxies[protocol][1], passwd = self.configuration.proxies[protocol][2], parent = parent, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR) dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_OK) response = dialog.run() if response == gtk.RESPONSE_OK: self.configuration.proxies[protocol][1] = dialog.user self.configuration.proxies[protocol][2] = dialog.passwd self.refresh_proxy_components() dialog.destroy() def rootfs_combo_changed_cb(self, rootfs_combo, all_package_format, check_hbox): combo_item = self.rootfs_combo.get_active_text() for child in check_hbox.get_children(): if isinstance(child, gtk.CheckButton): check_hbox.remove(child) for format in all_package_format: if format != combo_item: check_button = gtk.CheckButton(format) check_hbox.pack_start(check_button, expand=False, fill=False) check_hbox.show_all() def gen_pkgfmt_widget(self, curr_package_format, all_package_format, tooltip_combo="", tooltip_extra=""): pkgfmt_hbox = gtk.HBox(False, 24) rootfs_vbox = gtk.VBox(False, 6) pkgfmt_hbox.pack_start(rootfs_vbox, expand=False, fill=False) label = self.gen_label_widget("Root file system package format") rootfs_vbox.pack_start(label, expand=False, fill=False) rootfs_format = "" if curr_package_format: rootfs_format = curr_package_format.split()[0] rootfs_format_widget, rootfs_combo = self.gen_combo_widget(rootfs_format, all_package_format, tooltip_combo) rootfs_vbox.pack_start(rootfs_format_widget, expand=False, fill=False) extra_vbox = gtk.VBox(False, 6) pkgfmt_hbox.pack_start(extra_vbox, expand=False, fill=False) label = self.gen_label_widget("Additional package formats") extra_vbox.pack_start(label, expand=False, fill=False) check_hbox = gtk.HBox(False, 12) extra_vbox.pack_start(check_hbox, expand=False, fill=False) for format in all_package_format: if format != rootfs_format: check_button = gtk.CheckButton(format) is_active = (format in curr_package_format.split()) check_button.set_active(is_active) check_hbox.pack_start(check_button, expand=False, fill=False) info = HobInfoButton(tooltip_extra, self) check_hbox.pack_end(info, expand=False, fill=False) rootfs_combo.connect("changed", self.rootfs_combo_changed_cb, all_package_format, check_hbox) pkgfmt_hbox.show_all() return pkgfmt_hbox, rootfs_combo, check_hbox def editable_settings_cell_edited(self, cell, path_string, new_text, model): it = model.get_iter_from_string(path_string) column = cell.get_data("column") model.set(it, column, new_text) def editable_settings_add_item_clicked(self, button, model): new_item = ["##KEY##", "##VALUE##"] iter = model.append() model.set (iter, 0, new_item[0], 1, new_item[1], ) def editable_settings_remove_item_clicked(self, button, treeview): selection = treeview.get_selection() model, iter = selection.get_selected() if iter: path = model.get_path(iter)[0] model.remove(iter) def gen_editable_settings(self, setting, tooltip=""): setting_hbox = gtk.HBox(False, 12) vbox = gtk.VBox(False, 12) setting_hbox.pack_start(vbox, expand=True, fill=True) setting_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) for key in setting.keys(): setting_store.set(setting_store.append(), 0, key, 1, setting[key]) setting_tree = gtk.TreeView(setting_store) setting_tree.set_headers_visible(True) setting_tree.set_size_request(300, 100) col = gtk.TreeViewColumn('Key') col.set_min_width(100) col.set_max_width(150) col.set_resizable(True) col1 = gtk.TreeViewColumn('Value') col1.set_min_width(100) col1.set_max_width(150) col1.set_resizable(True) setting_tree.append_column(col) setting_tree.append_column(col1) cell = gtk.CellRendererText() cell.set_property('width-chars', 10) cell.set_property('editable', True) cell.set_data("column", 0) cell.connect("edited", self.editable_settings_cell_edited, setting_store) cell1 = gtk.CellRendererText() cell1.set_property('width-chars', 10) cell1.set_property('editable', True) cell1.set_data("column", 1) cell1.connect("edited", self.editable_settings_cell_edited, setting_store) col.pack_start(cell, True) col1.pack_end(cell1, True) col.set_attributes(cell, text=0) col1.set_attributes(cell1, text=1) scroll = gtk.ScrolledWindow() scroll.set_shadow_type(gtk.SHADOW_IN) scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(setting_tree) vbox.pack_start(scroll, expand=True, fill=True) # some buttons hbox = gtk.HBox(True, 6) vbox.pack_start(hbox, False, False) button = gtk.Button(stock=gtk.STOCK_ADD) button.connect("clicked", self.editable_settings_add_item_clicked, setting_store) hbox.pack_start(button) button = gtk.Button(stock=gtk.STOCK_REMOVE) button.connect("clicked", self.editable_settings_remove_item_clicked, setting_tree) hbox.pack_start(button) info = HobInfoButton(tooltip, self) setting_hbox.pack_start(info, expand=False, fill=False) return setting_hbox, setting_store def create_others_page(self): advanced_vbox = gtk.VBox(False, 6) advanced_vbox.set_border_width(6) sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=True, fill=True) label = self.gen_label_widget("<span weight=\"bold\">Add your own variables:</span>") tooltip = "These are key/value pairs for your extra settings. Click \'Add\' and then directly edit the key and the value" setting_widget, self.setting_store = self.gen_editable_settings(self.configuration.extra_setting,"<b>Add your own variables</b>" + "*" + tooltip) sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(setting_widget, expand=True, fill=True) return advanced_vbox def create_visual_elements(self): self.nb = gtk.Notebook() self.nb.set_show_tabs(True) self.nb.append_page(self.create_build_environment_page(), gtk.Label("Build environment")) self.nb.append_page(self.create_shared_state_page(), gtk.Label("Shared state")) self.nb.append_page(self.create_network_page(), gtk.Label("Network")) self.nb.append_page(self.create_others_page(), gtk.Label("Others")) self.nb.set_current_page(0) self.vbox.pack_start(self.nb, expand=True, fill=True) self.vbox.pack_end(gtk.HSeparator(), expand=True, fill=True) self.show_all() def destroy(self): self.handler.disconnect(self.proxy_test_passed_id) self.handler.disconnect(self.proxy_test_failed_id) super(SimpleSettingsDialog, self).destroy()
class BuildDetailsPage (HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0,) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.task_status = gtk.Label("\n") # to ensure layout is correct self.task_status.set_alignment(0.0, 0.5) self.progress_box.pack_start(self.task_status, expand=False, fill=False) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) self.stop_button.set_sensitive(False) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.notebook = HobNotebook() self.config_tv = BuildConfigurationTreeView() self.scrolled_view_config = gtk.ScrolledWindow () self.scrolled_view_config.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_config.add(self.config_tv) self.notebook.append_page(self.scrolled_view_config, "Build configuration") self.failure_tv = BuildFailureTreeView() self.failure_model = self.builder.handler.build.model.failure_model() self.failure_tv.set_model(self.failure_model) self.scrolled_view_failure = gtk.ScrolledWindow () self.scrolled_view_failure.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_failure.add(self.failure_tv) self.notebook.append_page(self.scrolled_view_failure, "Issues") self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow () self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.notebook.append_page(self.scrolled_view_build, "Log") self.builder.handler.build.model.connect_after("row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton('<< Back') self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def update_build_status(self, current, total, task): recipe_path, recipe_task = task.split(", ") recipe = os.path.basename(recipe_path).rstrip(".bb") tsk_msg = "<b>Running task %s of %s:</b> %s\n<b>Recipe:</b> %s" % (current, total, recipe_task, recipe) self.task_status.set_markup(tsk_msg) self.stop_button.set_sensitive(True) def reset_build_status(self): self.task_status.set_markup("\n") # to ensure layout is correct self.endpath = (0,) def show_issues(self): self.num_of_issues += 1 self.notebook.show_indicator_icon("Issues", self.num_of_issues) def reset_issues(self): self.num_of_issues = 0 self.notebook.hide_indicator_icon("Issues") def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def add_build_fail_top_bar(self, actions, log_file=None): primary_action = "Edit %s" % actions self.notebook.set_page("Issues") color = HobColors.ERROR build_fail_top = gtk.EventBox() build_fail_top.set_size_request(-1, 200) build_fail_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_fail_tab = gtk.Table(14, 46, True) build_fail_top.add(build_fail_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ERROR_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_fail_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_fail_tab.attach(label, 4, 26, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='medium'>Check the \"Issues\" information for more details</span>") build_fail_tab.attach(label, 4, 40, 4, 9) # create button 'Edit packages' action_button = HobButton(primary_action) action_button.set_size_request(-1, 40) action_button.set_tooltip_text("Edit the %s parameters" % actions) action_button.connect('clicked', self.failure_primary_action_button_clicked_cb, primary_action) build_fail_tab.attach(action_button, 4, 13, 9, 12) if log_file: open_log_button = HobAltButton("Open log") open_log_button.set_relief(gtk.RELIEF_HALF) open_log_button.set_tooltip_text("Open the build's log file") open_log_button.connect('clicked', self.failure_open_log_button_clicked_cb, log_file) build_fail_tab.attach(open_log_button, 14, 23, 9, 12) attach_pos = (24 if log_file else 14) file_bug_button = HobAltButton('File a bug') file_bug_button.set_relief(gtk.RELIEF_HALF) file_bug_button.set_tooltip_text("Open the Yocto Project bug tracking website") file_bug_button.connect('clicked', self.failure_activate_file_bug_link_cb) build_fail_tab.attach(file_bug_button, attach_pos, attach_pos + 9, 9, 12) return build_fail_top def show_fail_page(self, title, action_names): self._remove_all_widget() self.title = "Hob cannot build your %s" % title self.build_fail_bar = self.add_build_fail_top_bar(action_names, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_fail_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.config_tv.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() self.reset_build_status() self.reset_issues() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def show_configurations(self, configurations, params): self.config_tv.show(configurations, params) def failure_primary_action_button_clicked_cb(self, button, action): if "Edit recipes" in action: self.builder.show_recipes() elif "Edit packages" in action: self.builder.show_packages() elif "Edit image configuration" in action: self.builder.show_configuration() def failure_open_log_button_clicked_cb(self, button, log_file): if log_file: os.system("xdg-open /%s" % log_file) def failure_activate_file_bug_link_cb(self, button): button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")
class BuildDetailsPage(HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0, ) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.task_status = gtk.Label("\n") # to ensure layout is correct self.task_status.set_alignment(0.0, 0.5) self.progress_box.pack_start(self.task_status, expand=False, fill=False) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) self.stop_button.set_sensitive(False) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.notebook = HobNotebook() self.config_tv = BuildConfigurationTreeView() self.scrolled_view_config = gtk.ScrolledWindow() self.scrolled_view_config.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_config.add(self.config_tv) self.notebook.append_page(self.scrolled_view_config, gtk.Label("Build configuration")) self.failure_tv = BuildFailureTreeView() self.failure_model = self.builder.handler.build.model.failure_model() self.failure_tv.set_model(self.failure_model) self.scrolled_view_failure = gtk.ScrolledWindow() self.scrolled_view_failure.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_failure.add(self.failure_tv) self.notebook.append_page(self.scrolled_view_failure, gtk.Label("Issues")) self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow() self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.notebook.append_page(self.scrolled_view_build, gtk.Label("Log")) self.builder.handler.build.model.connect_after( "row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton("<< Back to image configuration") self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def update_build_status(self, current, total, task): recipe_path, recipe_task = task.split(", ") recipe = os.path.basename(recipe_path).rstrip(".bb") tsk_msg = "<b>Running task %s of %s:</b> %s\n<b>Recipe:</b> %s" % ( current, total, recipe_task, recipe) self.task_status.set_markup(tsk_msg) self.stop_button.set_sensitive(True) def reset_build_status(self): self.task_status.set_markup("\n") # to ensure layout is correct self.endpath = (0, ) def show_issues(self): self.num_of_issues += 1 self.notebook.show_indicator_icon("Issues", self.num_of_issues) def reset_issues(self): self.num_of_issues = 0 self.notebook.hide_indicator_icon("Issues") def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.config_tv.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() self.reset_build_status() self.reset_issues() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[ 0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def show_configurations(self, configurations, params): self.config_tv.show(configurations, params)
class BuildDetailsPage (HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0,) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.task_status = gtk.Label("\n") # to ensure layout is correct self.task_status.set_alignment(0.0, 0.5) self.progress_box.pack_start(self.task_status, expand=False, fill=False) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) self.stop_button.set_sensitive(False) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.notebook = HobNotebook() self.config_tv = BuildConfigurationTreeView() self.scrolled_view_config = gtk.ScrolledWindow () self.scrolled_view_config.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_config.add(self.config_tv) self.notebook.append_page(self.scrolled_view_config, gtk.Label("Build configuration")) self.failure_tv = BuildFailureTreeView() self.failure_model = self.builder.handler.build.model.failure_model() self.failure_tv.set_model(self.failure_model) self.scrolled_view_failure = gtk.ScrolledWindow () self.scrolled_view_failure.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_failure.add(self.failure_tv) self.notebook.append_page(self.scrolled_view_failure, gtk.Label("Issues")) self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow () self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.notebook.append_page(self.scrolled_view_build, gtk.Label("Log")) self.builder.handler.build.model.connect_after("row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton("<< Back to image configuration") self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def update_build_status(self, current, total, task): recipe_path, recipe_task = task.split(", ") recipe = os.path.basename(recipe_path).rstrip(".bb") tsk_msg = "<b>Running task %s of %s:</b> %s\n<b>Recipe:</b> %s" % (current, total, recipe_task, recipe) self.task_status.set_markup(tsk_msg) self.stop_button.set_sensitive(True) def reset_build_status(self): self.task_status.set_markup("\n") # to ensure layout is correct self.endpath = (0,) def show_issues(self): self.num_of_issues += 1 self.notebook.show_indicator_icon("Issues", self.num_of_issues) def reset_issues(self): self.num_of_issues = 0 self.notebook.hide_indicator_icon("Issues") def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.config_tv.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() self.reset_build_status() self.reset_issues() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def show_configurations(self, configurations, params): self.config_tv.show(configurations, params)
class BuildDetailsPage(HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0, ) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) tooltip = "Cancel build in progress" self.stop_button.set_tooltip_text(tooltip) self.stop_button.set_sensitive(True) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow() self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.builder.handler.build.model.connect_after( "row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton('<< Back') self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def reset_build_status(self): self.endpath = (0, ) def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def add_build_fail_top_bar(self, actions, log_file=None): primary_action = "Edit %s" % actions color = HobColors.ERROR build_fail_top = gtk.EventBox() #build_fail_top.set_size_request(-1, 200) build_fail_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_fail_tab = gtk.Table(14, 46, True) build_fail_top.add(build_fail_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file( hic.ICON_INDI_ERROR_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_fail_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_fail_tab.attach(label, 4, 40, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) # Ensure variable disk_full is defined if not hasattr(self.builder, 'disk_full'): self.builder.disk_full = False if self.builder.disk_full: markup = "<span size='medium'>There is no disk space left, so Hob cannot finish building your image. Free up some disk space\n" markup += "and restart the build." label.set_markup(markup) build_fail_tab.attach(label, 4, 40, 4, 9) # create button 'Edit packages' action_button = HobButton(primary_action) #action_button.set_size_request(-1, 40) action_button.set_tooltip_text("Edit the %s parameters" % actions) action_button.connect('clicked', self.failure_primary_action_button_clicked_cb, primary_action) if not self.builder.disk_full: build_fail_tab.attach(action_button, 4, 19, 9, 12) else: restart_build = HobButton("Restart the build") restart_build.set_tooltip_text("Restart the build") restart_build.connect('clicked', self.restart_build_button_clicked_cb) build_fail_tab.attach(restart_build, 4, 13, 9, 12) build_fail_tab.attach(action_button, 14, 23, 9, 12) self.builder.disk_full = False return build_fail_top def show_fail_page(self, title): self._remove_all_widget() self.title = "Hob cannot build your %s" % title self.build_fail_bar = self.add_build_fail_top_bar( title, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_fail_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.scrolled_view_build, expand=True, fill=True) self.show_all() self.back_button.hide() def add_build_stop_top_bar(self, action, log_file=None): color = HobColors.LIGHT_GRAY build_stop_top = gtk.EventBox() build_stop_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_stop_top.set_flags(gtk.CAN_DEFAULT) build_stop_top.grab_default() build_stop_tab = gtk.Table(11, 46, True) build_stop_top.add(build_stop_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file( hic.ICON_INFO_HOVER_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_stop_tab.attach(icon, 1, 4, 0, 6) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'><b>%s</b></span>" % self.title) build_stop_tab.attach(label, 4, 40, 0, 6) action_button = HobButton("Edit %s" % action) action_button.set_size_request(-1, 40) if action == "image": action_button.set_tooltip_text("Edit the image parameters") elif action == "recipes": action_button.set_tooltip_text("Edit the included recipes") elif action == "packages": action_button.set_tooltip_text("Edit the included packages") action_button.connect('clicked', self.stop_primary_action_button_clicked_cb, action) build_stop_tab.attach(action_button, 4, 20, 6, 9) build_button = HobAltButton("Build new image") build_button.set_tooltip_text("Create a new image from scratch") build_button.connect('clicked', self.new_image_button_clicked_cb) build_stop_tab.attach(build_button, 21, 40, 6, 9) return build_stop_top, action_button def show_stop_page(self, action): self._remove_all_widget() self.title = "Build stopped" self.build_stop_bar, action_button = self.add_build_stop_top_bar( action, self.builder.current_logfile) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.build_stop_bar, expand=False, fill=False) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.scrolled_view_build, expand=True, fill=True) self.show_all() self.back_button.hide() return action_button def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None, padding=15) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.scrolled_view_build, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() self.reset_build_status() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def new_image_button_clicked_cb(self, button): self.builder.populate_recipe_package_info_async() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[ 0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def failure_primary_action_button_clicked_cb(self, button, action): if "Edit recipes" in action: self.builder.show_recipes() elif "Edit packages" in action: self.builder.show_packages(ask=False) elif "Edit image" in action: self.builder.show_configuration() def restart_build_button_clicked_cb(self, button): self.builder.just_bake() def stop_primary_action_button_clicked_cb(self, button, action): if "recipes" in action: self.builder.show_recipes() elif "packages" in action: self.builder.show_packages(ask=False) elif "image" in action: self.builder.show_configuration() def open_log_button_clicked_cb(self, button, log_file): if log_file: log_file = "file:///" + log_file gtk.show_uri(screen=button.get_screen(), uri=log_file, timestamp=0) def failure_activate_file_bug_link_cb(self, button): button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")
class BuildDetailsPage (HobPage): def __init__(self, builder): super(BuildDetailsPage, self).__init__(builder, "Building ...") self.num_of_issues = 0 self.endpath = (0,) # create visual elements self.create_visual_elements() def create_visual_elements(self): # create visual elements self.vbox = gtk.VBox(False, 12) self.progress_box = gtk.VBox(False, 12) self.task_status = gtk.Label("\n") # to ensure layout is correct self.task_status.set_alignment(0.0, 0.5) self.progress_box.pack_start(self.task_status, expand=False, fill=False) self.progress_hbox = gtk.HBox(False, 6) self.progress_box.pack_end(self.progress_hbox, expand=True, fill=True) self.progress_bar = HobProgressBar() self.progress_hbox.pack_start(self.progress_bar, expand=True, fill=True) self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) self.stop_button.set_sensitive(False) self.progress_hbox.pack_end(self.stop_button, expand=False, fill=False) self.notebook = HobNotebook() self.config_tv = BuildConfigurationTreeView() self.scrolled_view_config = gtk.ScrolledWindow () self.scrolled_view_config.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_config.add(self.config_tv) self.notebook.append_page(self.scrolled_view_config, "Build configuration") self.failure_tv = BuildFailureTreeView() self.failure_model = self.builder.handler.build.model.failure_model() self.failure_tv.set_model(self.failure_model) self.scrolled_view_failure = gtk.ScrolledWindow () self.scrolled_view_failure.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_failure.add(self.failure_tv) self.notebook.append_page(self.scrolled_view_failure, "Issues") self.build_tv = RunningBuildTreeView(readonly=True, hob=True) self.build_tv.set_model(self.builder.handler.build.model) self.scrolled_view_build = gtk.ScrolledWindow () self.scrolled_view_build.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_view_build.add(self.build_tv) self.notebook.append_page(self.scrolled_view_build, "Log") self.builder.handler.build.model.connect_after("row-changed", self.scroll_to_present_row, self.scrolled_view_build.get_vadjustment(), self.build_tv) self.button_box = gtk.HBox(False, 6) self.back_button = HobAltButton("<< Back to image configuration") self.back_button.connect("clicked", self.back_button_clicked_cb) self.button_box.pack_start(self.back_button, expand=False, fill=False) def update_build_status(self, current, total, task): recipe_path, recipe_task = task.split(", ") recipe = os.path.basename(recipe_path).rstrip(".bb") tsk_msg = "<b>Running task %s of %s:</b> %s\n<b>Recipe:</b> %s" % (current, total, recipe_task, recipe) self.task_status.set_markup(tsk_msg) self.stop_button.set_sensitive(True) def reset_build_status(self): self.task_status.set_markup("\n") # to ensure layout is correct self.endpath = (0,) def show_issues(self): self.num_of_issues += 1 self.notebook.show_indicator_icon("Issues", self.num_of_issues) def reset_issues(self): self.num_of_issues = 0 self.notebook.hide_indicator_icon("Issues") def _remove_all_widget(self): children = self.vbox.get_children() or [] for child in children: self.vbox.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def update_failures_sum_display(self): num = 0 it = self.failure_model.get_iter_first() while it: color = self.failure_model.get_value(it, self.builder.handler.build.model.COL_COLOR) if color == HobColors.ERROR: num += 1 it = self.failure_model.iter_next(it) return num def add_build_fail_top_bar(self, actions): mainly_action = "Edit %s" % actions if 'image' in actions: next_action = "" else: next_action = "Create new image" #set to issue page self.notebook.set_page("Issues") color = HobColors.ERROR build_fail_top = gtk.EventBox() build_fail_top.set_size_request(-1, 260) build_fail_top.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) build_fail_tab = gtk.Table(7, 40, True) build_fail_top.add(build_fail_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ERROR_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_fail_tab.attach(icon, 1, 4, 0, 3) label = gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup("<span size='x-large'>%s</span>" % self.title) build_fail_tab.attach(label, 4, 20, 0, 3) label = gtk.Label() label.set_alignment(0.0, 0.5) num_of_fails = self.update_failures_sum_display() current_fail, recipe_task_status = self.task_status.get_text().split('\n') label.set_markup(" %d tasks failed, %s, %s" % (num_of_fails, current_fail, recipe_task_status)) build_fail_tab.attach(label, 4, 40, 2, 4) # create button 'Edit packages' action_button = HobButton(mainly_action) action_button.set_size_request(-1, 49) action_button.connect('clicked', self.failure_main_action_button_clicked_cb, mainly_action) build_fail_tab.attach(action_button, 4, 16, 4, 6) if next_action: next_button = HobAltButton(next_action) next_button.set_alignment(0.0, 0.5) next_button.connect('clicked', self.failure_next_action_button_clicked_cb, next_action) build_fail_tab.attach(next_button, 17, 24, 4, 5) file_bug_button = HobAltButton('File a bug') file_bug_button.set_alignment(0.0, 0.5) file_bug_button.connect('clicked', self.failure_file_bug_activate_link_cb) build_fail_tab.attach(file_bug_button, 17, 24, 4 + abs(next_action != ""), 6) return build_fail_top def show_fail_page(self, title, action_names): self._remove_all_widget() self.title = "Hob cannot build your %s" % title self.build_fail_bar = self.add_build_fail_top_bar(action_names) self.pack_start(self.build_fail_bar) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() def show_page(self, step): self._remove_all_widget() if step == self.builder.PACKAGE_GENERATING or step == self.builder.FAST_IMAGE_GENERATING: self.title = "Building packages ..." else: self.title = "Building image ..." self.build_details_top = self.add_onto_top_bar(None) self.pack_start(self.build_details_top, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.vbox, expand=True, fill=True) self.progress_bar.reset() self.config_tv.reset() self.vbox.pack_start(self.progress_box, expand=False, fill=False) self.vbox.pack_start(self.notebook, expand=True, fill=True) self.box_group_area.pack_end(self.button_box, expand=False, fill=False) self.show_all() self.back_button.hide() self.reset_build_status() self.reset_issues() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) self.progress_bar.set_title(title) self.progress_bar.set_rcstyle(status) def back_button_clicked_cb(self, button): self.builder.show_configuration() def show_back_button(self): self.back_button.show() def stop_button_clicked_cb(self, button): self.builder.stop_build() def hide_stop_button(self): self.stop_button.set_sensitive(False) self.stop_button.hide() def scroll_to_present_row(self, model, path, iter, v_adj, treeview): if treeview and v_adj: if path[0] > self.endpath[0]: # check the event is a new row append or not self.endpath = path # check the gtk.adjustment position is at end boundary or not if (v_adj.upper <= v_adj.page_size) or (v_adj.value == v_adj.upper - v_adj.page_size): treeview.scroll_to_cell(path) def show_configurations(self, configurations, params): self.config_tv.show(configurations, params) def failure_main_action_button_clicked_cb(self, button, action): if "Edit recipes" in action: self.builder.show_recipes() elif "Edit packages" in action: self.builder.show_packages() elif "Edit image configuration" in action: self.builder.show_configuration() def failure_next_action_button_clicked_cb(self, button, action): if "Create new image" in action: self.builder.initiate_new_build_async() def failure_file_bug_activate_link_cb(self, button): button.child.emit('activate-link', "http://bugzilla.yoctoproject.org")