コード例 #1
0
ファイル: sanitycheckpage.py プロジェクト: alex1818/yocto-iot
class SanityCheckPage (HobPage):

    def __init__(self, builder):
        super(SanityCheckPage, self).__init__(builder)
        self.running = False
        self.create_visual_elements()
        self.show_all()

    def make_label(self, text, bold=True):
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        mark = "<span %s>%s</span>" % (self.span_tag('x-large', 'bold') if bold else self.span_tag('medium'), text)
        label.set_markup(mark)
        return label

    def start(self):
        if not self.running:
          self.running = True
          gobject.timeout_add(100, self.timer_func)

    def stop(self):
        self.running = False

    def is_running(self):
        return self.running

    def timer_func(self):
        self.progress_bar.pulse()
        return self.running

    def create_visual_elements(self):
        # Table'd layout. 'rows' and 'cols' give the table size
        rows, cols = 30, 50
        self.table = gtk.Table(rows, cols, True)
        self.pack_start(self.table, expand=False, fill=False)
        sx, sy = 2, 2
        # 'info' icon
        image = gtk.Image()
        image.set_from_file(hic.ICON_INFO_DISPLAY_FILE)
        self.table.attach(image, sx, sx + 3, sy, sy + 3 )
        image.show()
        # 'Checking' message
        label = self.make_label('Checking for correct build system setup')
        self.table.attach(label, sx + 3, cols, sy, sy + 3, xpadding=5 )
        label.show()
        # 'Shouldn't take long' message.
        label = self.make_label("The check shouldn't take long.", False)
        self.table.attach(label, sx + 3, cols, sy + 3, sy + 4, xpadding=5)
        label.show()
        # Progress bar
        self.progress_bar = HobProgressBar()
        self.table.attach(self.progress_bar, sx + 3, cols - 3, sy + 5, sy + 7, xpadding=5)
        self.progress_bar.show()
        # All done
        self.table.show()
コード例 #2
0
    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)
コード例 #3
0
ファイル: sanitycheckpage.py プロジェクト: alex1818/yocto-iot
 def create_visual_elements(self):
     # Table'd layout. 'rows' and 'cols' give the table size
     rows, cols = 30, 50
     self.table = gtk.Table(rows, cols, True)
     self.pack_start(self.table, expand=False, fill=False)
     sx, sy = 2, 2
     # 'info' icon
     image = gtk.Image()
     image.set_from_file(hic.ICON_INFO_DISPLAY_FILE)
     self.table.attach(image, sx, sx + 3, sy, sy + 3 )
     image.show()
     # 'Checking' message
     label = self.make_label('Checking for correct build system setup')
     self.table.attach(label, sx + 3, cols, sy, sy + 3, xpadding=5 )
     label.show()
     # 'Shouldn't take long' message.
     label = self.make_label("The check shouldn't take long.", False)
     self.table.attach(label, sx + 3, cols, sy + 3, sy + 4, xpadding=5)
     label.show()
     # Progress bar
     self.progress_bar = HobProgressBar()
     self.table.attach(self.progress_bar, sx + 3, cols - 3, sy + 5, sy + 7, xpadding=5)
     self.progress_bar.show()
     # All done
     self.table.show()
コード例 #4
0
    def create_config_machine(self):
        self.machine_title = gtk.Label()
        self.machine_title.set_alignment(0.0, 0.5)
        mark = "<span %s>Select a machine</span>" % self.span_tag('x-large', 'bold')
        self.machine_title.set_markup(mark)

        self.machine_title_desc = gtk.Label()
        self.machine_title_desc.set_alignment(0.0, 0.5)
        mark = ("<span %s>Your selection is the profile of the target machine for which you"
        " are building the image.\n</span>") % (self.span_tag('medium'))
        self.machine_title_desc.set_markup(mark)

        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.connect("changed", self.machine_combo_changed_cb)

        icon_file = hic.ICON_LAYERS_DISPLAY_FILE
        hover_file = hic.ICON_LAYERS_HOVER_FILE
        self.layer_button = HobImageButton("Layers", "Add support for machines, software, etc.",
                                icon_file, hover_file)
        self.layer_button.connect("clicked", self.layer_button_clicked_cb)

        markup = "Layers are a powerful mechanism to extend the Yocto Project "
        markup += "with your own functionality.\n"
        markup += "For more on layers, check the <a href=\""
        markup += "http://www.yoctoproject.org/docs/current/dev-manual/"
        markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>."
        self.layer_info_icon = HobInfoButton(markup, self.get_parent())

#        self.progress_box = gtk.HBox(False, 6)
        self.progress_bar = HobProgressBar()
#        self.progress_box.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.progress_box.pack_end(stop_button, expand=False, fill=False)
        self.machine_separator = gtk.HSeparator()
コード例 #5
0
    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('&lt;&lt; Back')
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        self.button_box.pack_start(self.back_button, expand=False, fill=False)
コード例 #6
0
    def create_config_machine(self):
        self.machine_title = gtk.Label()
        self.machine_title.set_alignment(0.0, 0.5)
        mark = "<span %s>Select a machine</span>" % self.span_tag(
            'x-large', 'bold')
        self.machine_title.set_markup(mark)

        self.machine_title_desc = gtk.Label()
        self.machine_title_desc.set_alignment(0.0, 0.5)
        mark = (
            "<span %s>Your selection is the profile of the target machine for which you"
            " are building the image.\n</span>") % (self.span_tag('medium'))
        self.machine_title_desc.set_markup(mark)

        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.connect("changed", self.machine_combo_changed_cb)

        icon_file = hic.ICON_LAYERS_DISPLAY_FILE
        hover_file = hic.ICON_LAYERS_HOVER_FILE
        self.layer_button = HobImageButton(
            "Layers", "Add support for machines, software, etc.", icon_file,
            hover_file)
        self.layer_button.connect("clicked", self.layer_button_clicked_cb)

        markup = "Layers are a powerful mechanism to extend the Yocto Project "
        markup += "with your own functionality.\n"
        markup += "For more on layers, check the <a href=\""
        markup += "http://www.yoctoproject.org/docs/current/dev-manual/"
        markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>."
        self.layer_info_icon = HobInfoButton(markup, self.get_parent())

        #        self.progress_box = gtk.HBox(False, 6)
        self.progress_bar = HobProgressBar()
        #        self.progress_box.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.progress_box.pack_end(stop_button, expand=False, fill=False)
        self.machine_separator = gtk.HSeparator()
コード例 #7
0
    def create_visual_elements(self):
        hbox = gtk.HBox(False, 12)
        self.user_label = gtk.Label("The log will open in a text editor")
        hbox.pack_start(self.user_label, expand=False, fill=False)
        self.vbox.pack_start(hbox, expand=False, fill=False)

        hbox = gtk.HBox(False, 12)
        # Progress bar
        self.progress_bar = HobProgressBar()
        hbox.pack_start(self.progress_bar)
        self.start()
        self.vbox.pack_start(hbox, expand=False, fill=False)

        button = self.add_button("Cancel", gtk.RESPONSE_CANCEL)
        HobAltButton.style_button(button)
        self.show_all()
コード例 #8
0
    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("&lt;&lt; Back")
        self.back_button.connect("clicked", self.back_button_clicked_cb)
        self.button_box.pack_start(self.back_button, expand=False, fill=False)
コード例 #9
0
ファイル: hig.py プロジェクト: ReaLCodeBreaker/OE-gum
    def create_visual_elements(self):
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
        label.set_markup(markup)
        self.vbox.pack_start(label, expand=False, fill=False, padding=2)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        tv = gtk.TextView()
        tv.set_editable(False)
        tv.set_wrap_mode(gtk.WRAP_WORD)
        tv.set_cursor_visible(False)
        buf = gtk.TextBuffer()
        buf.set_text(self.image_path)
        tv.set_buffer(buf)
        scroll.add(tv)
        self.vbox.pack_start(scroll, expand=True, fill=True)

        self.usb_desc = gtk.Label()
        self.usb_desc.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
        self.usb_desc.set_markup(markup)

        self.usb_combo = gtk.combo_box_new_text()
        self.usb_combo.connect("changed", self.usb_combo_changed_cb)
        model = self.usb_combo.get_model()
        model.clear()
        self.usb_combo.append_text(self.__dummy_usb__)
        for usb in self.find_all_usb_devices():
            self.usb_combo.append_text("/dev/" + usb)
        self.usb_combo.set_active(0)
        self.vbox.pack_start(self.usb_combo, expand=True, fill=True)
        self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=True, padding=10)

        self.vbox.show_all()
        self.progress_bar.hide()
コード例 #10
0
    def create_visual_elements(self):
        # create visual elements
        self.vbox = gtk.VBox(False, 15)

        self.progress_box = gtk.HBox(False, 5)
        self.progress_bar = HobProgressBar()
        self.progress_box.pack_start(self.progress_bar, expand=True, fill=True)
        self.stop_button = gtk.LinkButton("Stop the build process", "Stop")
        self.stop_button.connect("clicked", self.stop_button_clicked_cb)
        self.progress_box.pack_end(self.stop_button, expand=False, fill=False)

        self.build_tv = RunningBuildTreeView(readonly=True)
        self.build_tv.set_model(self.builder.handler.build.model)
        self.scrolled_view = gtk.ScrolledWindow ()
        self.scrolled_view.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scrolled_view.add(self.build_tv)

        self.button_box = gtk.HBox(False, 5)
        self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< 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)
コード例 #11
0
    def create_visual_elements(self):
        # create visual elements
        self.vbox = gtk.VBox(False, 12)

        self.progress_box = gtk.HBox(False, 6)
        self.progress_bar = HobProgressBar()
        self.progress_box.pack_start(self.progress_bar, expand=True, fill=True)
        self.stop_button = gtk.LinkButton("Stop the build process", "Stop")
        self.stop_button.connect("clicked", self.stop_button_clicked_cb)
        self.progress_box.pack_end(self.stop_button, expand=False, fill=False)

        self.notebook = HobNotebook()
        self.config_tv = BuildConfigurationTreeView()
        self.config_model = self.builder.handler.build.model.config_model()
        self.config_tv.set_model(self.config_model)
        self.scrolled_view_config = gtk.ScrolledWindow ()
        self.scrolled_view_config.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        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_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        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)
        self.build_tv.set_model(self.builder.handler.build.model)
        self.scrolled_view_build = gtk.ScrolledWindow ()
        self.scrolled_view_build.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scrolled_view_build.add(self.build_tv)
        self.notebook.append_page(self.scrolled_view_build, gtk.Label("Log"))

        self.button_box = gtk.HBox(False, 6)
        self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< 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)
コード例 #12
0
ファイル: builddetailspage.py プロジェクト: TizenTeam/poky
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")
コード例 #13
0
    def create_visual_elements(self):
        self.set_size_request(600, 400)
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
        label.set_markup(markup)
        self.vbox.pack_start(label, expand=False, fill=False, padding=2)

        table = gtk.Table(2, 10, False)
        table.set_col_spacings(5)
        table.set_row_spacings(5)
        self.vbox.pack_start(table, expand=True, fill=True)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        tv = gtk.TextView()
        tv.set_editable(False)
        tv.set_wrap_mode(gtk.WRAP_WORD)
        tv.set_cursor_visible(False)
        self.buf = gtk.TextBuffer()
        self.buf.set_text(self.image_path)
        tv.set_buffer(self.buf)
        scroll.add(tv)
        table.attach(scroll, 0, 10, 0, 1)

        # There are 2 ways to use DeployImageDialog
        # One way is that called by HOB when the 'Deploy Image' button is clicked
        # The other way is that called by a standalone script.
        # Following block of codes handles the latter way. It adds a 'Select Image' button and
        # emit a signal when the button is clicked.
        if self.standalone:
            gobject.signal_new("select_image_clicked", self,
                               gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
            icon = gtk.Image()
            pix_buffer = gtk.gdk.pixbuf_new_from_file(
                hic.ICON_IMAGES_DISPLAY_FILE)
            icon.set_from_pixbuf(pix_buffer)
            button = gtk.Button("Select Image")
            button.set_image(icon)
            #button.set_size_request(140, 50)
            table.attach(button, 9, 10, 1, 2, gtk.FILL, 0, 0, 0)
            button.connect("clicked", self.select_image_button_clicked_cb)

        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=False, padding=10)

        self.usb_desc = gtk.Label()
        self.usb_desc.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
        self.usb_desc.set_markup(markup)

        self.usb_combo = gtk.combo_box_new_text()
        self.usb_combo.connect("changed", self.usb_combo_changed_cb)
        model = self.usb_combo.get_model()
        model.clear()
        self.usb_combo.append_text(self.__dummy_usb__)
        for usb in self.find_all_usb_devices():
            self.usb_combo.append_text("/dev/" + usb)
        self.usb_combo.set_active(0)
        self.vbox.pack_start(self.usb_combo, expand=False, fill=False)
        self.vbox.pack_start(self.usb_desc,
                             expand=False,
                             fill=False,
                             padding=2)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=True, padding=10)

        self.vbox.show_all()
        self.progress_bar.hide()
コード例 #14
0
class BuildDetailsPage (HobPage):

    def __init__(self, builder):
        super(BuildDetailsPage, self).__init__(builder, "Building ...")

        self.num_of_issues = 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.HBox(False, 6)
        self.progress_bar = HobProgressBar()
        self.progress_box.pack_start(self.progress_bar, expand=True, fill=True)
        self.stop_button = gtk.LinkButton("Stop the build process", "Stop")
        self.stop_button.connect("clicked", self.stop_button_clicked_cb)
        self.progress_box.pack_end(self.stop_button, expand=False, fill=False)

        self.notebook = HobNotebook()
        self.config_tv = BuildConfigurationTreeView()
        self.config_model = self.builder.handler.build.model.config_model()
        self.config_tv.set_model(self.config_model)
        self.scrolled_view_config = gtk.ScrolledWindow ()
        self.scrolled_view_config.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        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_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        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)
        self.build_tv.set_model(self.builder.handler.build.model)
        self.scrolled_view_build = gtk.ScrolledWindow ()
        self.scrolled_view_build.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scrolled_view_build.add(self.build_tv)
        self.notebook.append_page(self.scrolled_view_build, gtk.Label("Log"))

        self.button_box = gtk.HBox(False, 6)
        self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< 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 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.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()

    def update_progress_bar(self, title, fraction, status=True):
        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.hide()
コード例 #15
0
class DeployImageDialog(CrumbsDialog):

    __dummy_usb__ = "--select a usb drive--"

    def __init__(self,
                 title,
                 image_path,
                 parent,
                 flags,
                 buttons=None,
                 standalone=False):
        super(DeployImageDialog, self).__init__(title, parent, flags, buttons)

        self.image_path = image_path
        self.standalone = standalone

        self.create_visual_elements()
        self.connect("response", self.response_cb)

    def create_visual_elements(self):
        self.set_size_request(600, 400)
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
        label.set_markup(markup)
        self.vbox.pack_start(label, expand=False, fill=False, padding=2)

        table = gtk.Table(2, 10, False)
        table.set_col_spacings(5)
        table.set_row_spacings(5)
        self.vbox.pack_start(table, expand=True, fill=True)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        tv = gtk.TextView()
        tv.set_editable(False)
        tv.set_wrap_mode(gtk.WRAP_WORD)
        tv.set_cursor_visible(False)
        self.buf = gtk.TextBuffer()
        self.buf.set_text(self.image_path)
        tv.set_buffer(self.buf)
        scroll.add(tv)
        table.attach(scroll, 0, 10, 0, 1)

        # There are 2 ways to use DeployImageDialog
        # One way is that called by HOB when the 'Deploy Image' button is clicked
        # The other way is that called by a standalone script.
        # Following block of codes handles the latter way. It adds a 'Select Image' button and
        # emit a signal when the button is clicked.
        if self.standalone:
            gobject.signal_new("select_image_clicked", self,
                               gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
            icon = gtk.Image()
            pix_buffer = gtk.gdk.pixbuf_new_from_file(
                hic.ICON_IMAGES_DISPLAY_FILE)
            icon.set_from_pixbuf(pix_buffer)
            button = gtk.Button("Select Image")
            button.set_image(icon)
            #button.set_size_request(140, 50)
            table.attach(button, 9, 10, 1, 2, gtk.FILL, 0, 0, 0)
            button.connect("clicked", self.select_image_button_clicked_cb)

        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=False, padding=10)

        self.usb_desc = gtk.Label()
        self.usb_desc.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
        self.usb_desc.set_markup(markup)

        self.usb_combo = gtk.combo_box_new_text()
        self.usb_combo.connect("changed", self.usb_combo_changed_cb)
        model = self.usb_combo.get_model()
        model.clear()
        self.usb_combo.append_text(self.__dummy_usb__)
        for usb in self.find_all_usb_devices():
            self.usb_combo.append_text("/dev/" + usb)
        self.usb_combo.set_active(0)
        self.vbox.pack_start(self.usb_combo, expand=False, fill=False)
        self.vbox.pack_start(self.usb_desc,
                             expand=False,
                             fill=False,
                             padding=2)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=True, padding=10)

        self.vbox.show_all()
        self.progress_bar.hide()

    def set_image_text_buffer(self, image_path):
        self.buf.set_text(image_path)

    def set_image_path(self, image_path):
        self.image_path = image_path

    def popen_read(self, cmd):
        tmpout, errors = bb.process.run("%s" % cmd)
        return tmpout.strip()

    def find_all_usb_devices(self):
        usb_devs = [
            os.readlink(u) for u in glob.glob('/dev/disk/by-id/usb*')
            if not re.search(r'part\d+', u)
        ]
        return ['%s' % u[u.rfind('/') + 1:] for u in usb_devs]

    def get_usb_info(self, dev):
        return "%s %s" % \
            (self.popen_read('cat /sys/class/block/%s/device/vendor' % dev),
            self.popen_read('cat /sys/class/block/%s/device/model' % dev))

    def select_image_button_clicked_cb(self, button):
        self.emit('select_image_clicked')

    def usb_combo_changed_cb(self, usb_combo):
        combo_item = self.usb_combo.get_active_text()
        if not combo_item or combo_item == self.__dummy_usb__:
            markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
            self.usb_desc.set_markup(markup)
        else:
            markup = "<span font_desc='12'>" + self.get_usb_info(
                combo_item.lstrip("/dev/")) + "</span>"
            self.usb_desc.set_markup(markup)

    def response_cb(self, dialog, response_id):
        if response_id == gtk.RESPONSE_YES:
            lbl = ''
            msg = ''
            combo_item = self.usb_combo.get_active_text()
            if combo_item and combo_item != self.__dummy_usb__ and self.image_path:
                cmdline = bb.ui.crumbs.utils.which_terminal()
                if cmdline:
                    tmpfile = tempfile.NamedTemporaryFile()
                    cmdline += "\"sudo dd if=" + self.image_path + \
                                " of=" + combo_item + " && sync; echo $? > " + tmpfile.name + "\""
                    subprocess.call(shlex.split(cmdline))

                    if int(tmpfile.readline().strip()) == 0:
                        lbl = "<b>Deploy image successfully.</b>"
                    else:
                        lbl = "<b>Failed to deploy image.</b>"
                        msg = "Please check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (
                            self.image_path, combo_item)
                    tmpfile.close()
            else:
                if not self.image_path:
                    lbl = "<b>No selection made.</b>"
                    msg = "You have not selected an image to deploy."
                else:
                    lbl = "<b>No selection made.</b>"
                    msg = "You have not selected a USB device."
            if len(lbl):
                crumbs_dialog = CrumbsMessageDialog(self, lbl,
                                                    gtk.MESSAGE_INFO, msg)
                button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK)
                HobButton.style_button(button)
                crumbs_dialog.run()
                crumbs_dialog.destroy()

    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 write_file(self, ifile, ofile):
        self.progress_bar.reset()
        self.progress_bar.show()

        f_from = os.open(ifile, os.O_RDONLY)
        f_to = os.open(ofile, os.O_WRONLY)

        total_size = os.stat(ifile).st_size
        written_size = 0

        while True:
            buf = os.read(f_from, 1024 * 1024)
            if not buf:
                break
            os.write(f_to, buf)
            written_size += 1024 * 1024
            self.update_progress_bar("Writing to usb:",
                                     written_size * 1.0 / total_size)

        self.update_progress_bar("Writing completed:", 1.0)
        os.close(f_from)
        os.close(f_to)
        self.progress_bar.hide()
コード例 #16
0
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('&lt;&lt; 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")
コード例 #17
0
ファイル: deployimagedialog.py プロジェクト: 117111302/poky
class DeployImageDialog (CrumbsDialog):

    __dummy_usb__ = "--select a usb drive--"

    def __init__(self, title, image_path, parent, flags, buttons=None, standalone=False):
        super(DeployImageDialog, self).__init__(title, parent, flags, buttons)

        self.image_path = image_path
        self.standalone = standalone

        self.create_visual_elements()
        self.connect("response", self.response_cb)

    def create_visual_elements(self):
        self.set_size_request(600, 400)
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
        label.set_markup(markup)
        self.vbox.pack_start(label, expand=False, fill=False, padding=2)

        table = gtk.Table(2, 10, False)
        table.set_col_spacings(5)
        table.set_row_spacings(5)
        self.vbox.pack_start(table, expand=True, fill=True)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        tv = gtk.TextView()
        tv.set_editable(False)
        tv.set_wrap_mode(gtk.WRAP_WORD)
        tv.set_cursor_visible(False)
        self.buf = gtk.TextBuffer()
        self.buf.set_text(self.image_path)
        tv.set_buffer(self.buf)
        scroll.add(tv)
        table.attach(scroll, 0, 10, 0, 1)

        # There are 2 ways to use DeployImageDialog
        # One way is that called by HOB when the 'Deploy Image' button is clicked
        # The other way is that called by a standalone script.
        # Following block of codes handles the latter way. It adds a 'Select Image' button and
        # emit a signal when the button is clicked.
        if self.standalone:
                gobject.signal_new("select_image_clicked", self, gobject.SIGNAL_RUN_FIRST,
                                   gobject.TYPE_NONE, ())
                icon = gtk.Image()
                pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_IMAGES_DISPLAY_FILE)
                icon.set_from_pixbuf(pix_buffer)
                button = gtk.Button("Select Image")
                button.set_image(icon)
                #button.set_size_request(140, 50)
                table.attach(button, 9, 10, 1, 2, gtk.FILL, 0, 0, 0)
                button.connect("clicked", self.select_image_button_clicked_cb)

        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=False, padding=10)

        self.usb_desc = gtk.Label()
        self.usb_desc.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
        self.usb_desc.set_markup(markup)

        self.usb_combo = gtk.combo_box_new_text()
        self.usb_combo.connect("changed", self.usb_combo_changed_cb)
        model = self.usb_combo.get_model()
        model.clear()
        self.usb_combo.append_text(self.__dummy_usb__)
        for usb in self.find_all_usb_devices():
            self.usb_combo.append_text("/dev/" + usb)
        self.usb_combo.set_active(0)
        self.vbox.pack_start(self.usb_combo, expand=False, fill=False)
        self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=True, padding=10)

        self.vbox.show_all()
        self.progress_bar.hide()

    def set_image_text_buffer(self, image_path):
        self.buf.set_text(image_path)

    def set_image_path(self, image_path):
        self.image_path = image_path

    def popen_read(self, cmd):
        tmpout, errors = bb.process.run("%s" % cmd)
        return tmpout.strip()

    def find_all_usb_devices(self):
        usb_devs = [ os.readlink(u)
            for u in glob.glob('/dev/disk/by-id/usb*')
            if not re.search(r'part\d+', u) ]
        return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ]

    def get_usb_info(self, dev):
        return "%s %s" % \
            (self.popen_read('cat /sys/class/block/%s/device/vendor' % dev),
            self.popen_read('cat /sys/class/block/%s/device/model' % dev))

    def select_image_button_clicked_cb(self, button):
            self.emit('select_image_clicked')

    def usb_combo_changed_cb(self, usb_combo):
        combo_item = self.usb_combo.get_active_text()
        if not combo_item or combo_item == self.__dummy_usb__:
            markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
            self.usb_desc.set_markup(markup)
        else:
            markup = "<span font_desc='12'>" + self.get_usb_info(combo_item.lstrip("/dev/")) + "</span>"
            self.usb_desc.set_markup(markup)

    def response_cb(self, dialog, response_id):
        if response_id == gtk.RESPONSE_YES:
            lbl = ''
            msg = ''
            combo_item = self.usb_combo.get_active_text()
            if combo_item and combo_item != self.__dummy_usb__ and self.image_path:
                cmdline = bb.ui.crumbs.utils.which_terminal()
                if cmdline:
                    tmpfile = tempfile.NamedTemporaryFile()
                    cmdline += "\"sudo dd if=" + self.image_path + \
                                " of=" + combo_item + " && sync; echo $? > " + tmpfile.name + "\""
                    subprocess.call(shlex.split(cmdline))

                    if int(tmpfile.readline().strip()) == 0:
                        lbl = "<b>Deploy image successfully.</b>"
                    else:
                        lbl = "<b>Failed to deploy image.</b>"
                        msg = "Please check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (self.image_path, combo_item)
                    tmpfile.close()
            else:
                if not self.image_path:
                    lbl = "<b>No selection made.</b>"
                    msg = "You have not selected an image to deploy."
                else:
                    lbl = "<b>No selection made.</b>"
                    msg = "You have not selected a USB device."
            if len(lbl):
                crumbs_dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO, msg)
                button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK)
                HobButton.style_button(button)
                crumbs_dialog.run()
                crumbs_dialog.destroy()

    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 write_file(self, ifile, ofile):
        self.progress_bar.reset()
        self.progress_bar.show()

        f_from = os.open(ifile, os.O_RDONLY)
        f_to = os.open(ofile, os.O_WRONLY)

        total_size = os.stat(ifile).st_size
        written_size = 0

        while True:
            buf = os.read(f_from, 1024*1024)
            if not buf:
                break
            os.write(f_to, buf)
            written_size += 1024*1024
            self.update_progress_bar("Writing to usb:", written_size * 1.0/total_size)

        self.update_progress_bar("Writing completed:", 1.0)
        os.close(f_from)
        os.close(f_to)
        self.progress_bar.hide()
コード例 #18
0
def main(server, eventHandler):
    try:
        cmdline = server.runCommand(["getCmdLineAction"])
        if cmdline and not cmdline['action']:
            print(cmdline['msg'])
            return
        elif not cmdline or (cmdline['action'] and cmdline['action'][0] != "generateDotGraph"):
            print("This UI is only compatible with the -g option")
            return
        ret = server.runCommand(["generateDepTreeEvent", cmdline['action'][1], cmdline['action'][2]])
        if ret != True:
            print("Couldn't run command! %s" % ret)
            return
    except xmlrpclib.Fault as x:
        print("XMLRPC Fault getting commandline:\n %s" % x)
        return

    shutdown = 0

    gtkgui = gtkthread(shutdown)
    gtkgui.start()

    gtk.gdk.threads_enter()
    dep = DepExplorer()
    bardialog = gtk.Dialog(parent=dep)
    bardialog.set_default_size(400, 50)
    pbar = HobProgressBar()
    bardialog.vbox.pack_start(pbar)
    bardialog.show_all()
    bardialog.connect("delete-event", gtk.main_quit)
    gtk.gdk.threads_leave()

    progress_total = 0
    while True:
        try:
            event = eventHandler.waitEvent(0.25)
            if gtkthread.quit.isSet():
                server.runCommand(["stateStop"])
                break

            if event is None:
                continue

            if isinstance(event, bb.event.CacheLoadStarted):
                progress_total = event.total
                gtk.gdk.threads_enter()
                bardialog.set_title("Loading Cache")
                pbar.update(0)
                gtk.gdk.threads_leave()

            if isinstance(event, bb.event.CacheLoadProgress):
                x = event.current
                gtk.gdk.threads_enter()
                pbar.update(x * 1.0 / progress_total)
                pbar.set_title('')
                gtk.gdk.threads_leave()
                continue

            if isinstance(event, bb.event.CacheLoadCompleted):
                bardialog.hide()
                continue

            if isinstance(event, bb.event.ParseStarted):
                progress_total = event.total
                if progress_total == 0:
                    continue
                gtk.gdk.threads_enter()
                pbar.update(0)
                bardialog.set_title("Processing recipes")

                gtk.gdk.threads_leave()

            if isinstance(event, bb.event.ParseProgress):
                x = event.current
                gtk.gdk.threads_enter()
                pbar.update(x * 1.0 / progress_total)
                pbar.set_title('')
                gtk.gdk.threads_leave()
                continue

            if isinstance(event, bb.event.ParseCompleted):
                bardialog.hide()
                continue

            if isinstance(event, bb.event.DepTreeGenerated):
                gtk.gdk.threads_enter()
                parse(event._depgraph, dep.pkg_model, dep.depends_model)
                gtk.gdk.threads_leave()

            if isinstance(event, bb.command.CommandCompleted):
                continue

            if isinstance(event, bb.command.CommandFailed):
                print("Command execution failed: %s" % event.error)
                return event.exitcode

            if isinstance(event, bb.command.CommandExit):
                return event.exitcode

            if isinstance(event, bb.cooker.CookerExit):
                break

            continue
        except EnvironmentError as ioerror:
            # ignore interrupted io
            if ioerror.args[0] == 4:
                pass
        except KeyboardInterrupt:
            if shutdown == 2:
                print("\nThird Keyboard Interrupt, exit.\n")
                break
            if shutdown == 1:
                print("\nSecond Keyboard Interrupt, stopping...\n")
                server.runCommand(["stateStop"])
            if shutdown == 0:
                print("\nKeyboard Interrupt, closing down...\n")
                server.runCommand(["stateShutdown"])
            shutdown = shutdown + 1
            pass
コード例 #19
0
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")
コード例 #20
0
class SanityCheckPage(HobPage):
    def __init__(self, builder):
        super(SanityCheckPage, self).__init__(builder)
        self.running = False
        self.create_visual_elements()
        self.show_all()

    def make_label(self, text, bold=True):
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        mark = "<span %s>%s</span>" % (self.span_tag('x-large', 'bold') if bold
                                       else self.span_tag('medium'), text)
        label.set_markup(mark)
        return label

    def start(self):
        if not self.running:
            self.running = True
            gobject.timeout_add(100, self.timer_func)

    def stop(self):
        self.running = False

    def is_running(self):
        return self.running

    def timer_func(self):
        self.progress_bar.pulse()
        return self.running

    def create_visual_elements(self):
        # Table'd layout. 'rows' and 'cols' give the table size
        rows, cols = 30, 50
        self.table = gtk.Table(rows, cols, True)
        self.pack_start(self.table, expand=False, fill=False)
        sx, sy = 2, 2
        # 'info' icon
        image = gtk.Image()
        image.set_from_file(hic.ICON_INFO_DISPLAY_FILE)
        self.table.attach(image, sx, sx + 2, sy, sy + 3)
        image.show()
        # 'Checking' message
        label = self.make_label(
            'Hob is checking for correct build system setup')
        self.table.attach(label, sx + 2, cols, sy, sy + 3, xpadding=5)
        label.show()
        # 'Shouldn't take long' message.
        label = self.make_label("The check shouldn't take long.", False)
        self.table.attach(label, sx + 2, cols, sy + 3, sy + 4, xpadding=5)
        label.show()
        # Progress bar
        self.progress_bar = HobProgressBar()
        self.table.attach(self.progress_bar,
                          sx + 2,
                          cols - 3,
                          sy + 5,
                          sy + 7,
                          xpadding=5)
        self.progress_bar.show()
        # All done
        self.table.show()
コード例 #21
0
    def create_visual_elements(self):
        if not self.devices:
            self.set_size_request(400, 200)
            first_column = gtk.HBox(spacing=6)
            first_column.set_property("border-width", 6)
            first_column.show()
            self.vbox.add(first_column)
            icon = gtk.Image()
            icon_chk = HobIconChecker()
            icon.set_from_stock(icon_chk.check_stock_icon(gtk.STOCK_DIALOG_WARNING), gtk.ICON_SIZE_DIALOG)
            icon.set_property("xalign", 0.00)
            first_column.pack_start(icon, expand=False, fill=True, padding=0)

            label = gtk.Label()
            label.set_use_markup(True)
            label.set_line_wrap(True)
            label.set_markup("<span font_desc='17' weight=\'bold\'>No external storage\ndevice found</span>")
            label.set_property("xalign", 0.00)
            first_column.add(label)

            label = gtk.Label()
            label.set_use_markup(True)
            label.set_line_wrap(True)
            label.set_markup("<span font_desc='12'>Insert an SD card or USB drive before\ndeploying your image</span>")
            label.set_property("yalign", 0.00)
            self.vbox.add(label)

            button = self.add_button("OK", gtk.RESPONSE_CANCEL)
            HobAltButton.style_button(button)

        else:
            self.set_size_request(350, 300)
            label = gtk.Label()
            label.set_alignment(0.0, 0.5)
            markup = "<span font_desc='17' weight=\'bold\'>External storage device</span>"
            label.set_markup(markup)
            self.vbox.pack_start(label, expand=False, fill=False, padding=2)

            self.device_vendor = gtk.Label()
            self.device_vendor.set_alignment(0.0, 0.5)
            vendor = self.get_vendor_info(self.devices[0])
            if vendor is None:
                vendor = "Not known"
            markup = "<span font_desc='12'>Vendor: %s</span>" % vendor
            self.device_vendor.set_markup(markup)

            self.device_model = gtk.Label()
            self.device_model.set_alignment(0.0, 0.5)
            model = self.get_model_info(self.devices[0])
            if model is None:
                model = "Not known"
            markup = "<span font_desc='12'>Model: %s</span>" % model
            self.device_model.set_markup(markup)

            self.device_size = gtk.Label()
            self.device_size.set_alignment(0.0, 0.5)
            size = float(self.get_size_info(self.devices[0])) * 512 / 1024 / 1024
            if size > 1024:
                size = size/1024
                markup = "<span font_desc='12'>Size: %.2f GB</span>" % size
            else:
                markup = "<span font_desc='12'>Size: %.2f MB</span>" % size
            self.device_size.set_markup(markup)

            if len(self.devices) == 1:
                label = gtk.Label()
                label.set_alignment(0.0, 0.5)
                markup = "<span font_desc='12'>/dev/%s</span>" % self.devices[0]
                label.set_markup(markup)
                self.vbox.pack_start(label, expand=False, fill=False, padding=2)
            else:
                self.usb_combo = gtk.combo_box_new_text()
                self.usb_combo.connect("changed", self.usb_combo_changed_cb)
                model = self.usb_combo.get_model()
                model.clear()
                for usb in self.devices:
                    self.usb_combo.append_text("/dev/" + usb)
                self.usb_combo.set_active(0)
                self.vbox.pack_start(self.usb_combo, expand=False, fill=False)

            label = gtk.Label()
            label.set_alignment(0.0, 0.5)
            markup = "<span font_desc='17' weight=\'bold\'>Device details</span>"
            label.set_markup(markup)
            self.vbox.pack_start(label, expand=False, fill=False, padding=2)

            self.vbox.pack_start(self.device_vendor, expand=False, fill=False, padding=2)
            self.vbox.pack_start(self.device_model, expand=False, fill=False, padding=2)
            self.vbox.pack_start(self.device_size, expand=False, fill=False, padding=2)

            button = self.add_button("Cancel", gtk.RESPONSE_NO)
            HobAltButton.style_button(button)
            button = self.add_button("Deploy image", gtk.RESPONSE_YES)
            tooltip = "Burn your image to an external storage device"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)

        self.vbox.show_all()
        self.progress_bar.hide()
コード例 #22
0
class DeployImageDialog (CrumbsDialog):

    __dummy_usb__ = "--select a usb drive--"

    def __init__(self, builder, title, image, parent, flags, buttons=None, standalone=False):
        super(DeployImageDialog, self).__init__(title, parent, flags, buttons)

        self.image = image.split("-clanton-")[0]
        self.builder = builder
        self.standalone = standalone

        self.devices = self.find_all_external_devices()
        self.create_visual_elements()
        self.connect("response", self.response_cb)

    def create_visual_elements(self):
        if not self.devices:
            self.set_size_request(400, 200)
            first_column = gtk.HBox(spacing=6)
            first_column.set_property("border-width", 6)
            first_column.show()
            self.vbox.add(first_column)
            icon = gtk.Image()
            icon_chk = HobIconChecker()
            icon.set_from_stock(icon_chk.check_stock_icon(gtk.STOCK_DIALOG_WARNING), gtk.ICON_SIZE_DIALOG)
            icon.set_property("xalign", 0.00)
            first_column.pack_start(icon, expand=False, fill=True, padding=0)

            label = gtk.Label()
            label.set_use_markup(True)
            label.set_line_wrap(True)
            label.set_markup("<span font_desc='17' weight=\'bold\'>No external storage\ndevice found</span>")
            label.set_property("xalign", 0.00)
            first_column.add(label)

            label = gtk.Label()
            label.set_use_markup(True)
            label.set_line_wrap(True)
            label.set_markup("<span font_desc='12'>Insert an SD card or USB drive before\ndeploying your image</span>")
            label.set_property("yalign", 0.00)
            self.vbox.add(label)

            button = self.add_button("OK", gtk.RESPONSE_CANCEL)
            HobAltButton.style_button(button)

        else:
            self.set_size_request(350, 300)
            label = gtk.Label()
            label.set_alignment(0.0, 0.5)
            markup = "<span font_desc='17' weight=\'bold\'>External storage device</span>"
            label.set_markup(markup)
            self.vbox.pack_start(label, expand=False, fill=False, padding=2)

            self.device_vendor = gtk.Label()
            self.device_vendor.set_alignment(0.0, 0.5)
            vendor = self.get_vendor_info(self.devices[0])
            if vendor is None:
                vendor = "Not known"
            markup = "<span font_desc='12'>Vendor: %s</span>" % vendor
            self.device_vendor.set_markup(markup)

            self.device_model = gtk.Label()
            self.device_model.set_alignment(0.0, 0.5)
            model = self.get_model_info(self.devices[0])
            if model is None:
                model = "Not known"
            markup = "<span font_desc='12'>Model: %s</span>" % model
            self.device_model.set_markup(markup)

            self.device_size = gtk.Label()
            self.device_size.set_alignment(0.0, 0.5)
            size = float(self.get_size_info(self.devices[0])) * 512 / 1024 / 1024
            if size > 1024:
                size = size/1024
                markup = "<span font_desc='12'>Size: %.2f GB</span>" % size
            else:
                markup = "<span font_desc='12'>Size: %.2f MB</span>" % size
            self.device_size.set_markup(markup)

            if len(self.devices) == 1:
                label = gtk.Label()
                label.set_alignment(0.0, 0.5)
                markup = "<span font_desc='12'>/dev/%s</span>" % self.devices[0]
                label.set_markup(markup)
                self.vbox.pack_start(label, expand=False, fill=False, padding=2)
            else:
                self.usb_combo = gtk.combo_box_new_text()
                self.usb_combo.connect("changed", self.usb_combo_changed_cb)
                model = self.usb_combo.get_model()
                model.clear()
                for usb in self.devices:
                    self.usb_combo.append_text("/dev/" + usb)
                self.usb_combo.set_active(0)
                self.vbox.pack_start(self.usb_combo, expand=False, fill=False)

            label = gtk.Label()
            label.set_alignment(0.0, 0.5)
            markup = "<span font_desc='17' weight=\'bold\'>Device details</span>"
            label.set_markup(markup)
            self.vbox.pack_start(label, expand=False, fill=False, padding=2)

            self.vbox.pack_start(self.device_vendor, expand=False, fill=False, padding=2)
            self.vbox.pack_start(self.device_model, expand=False, fill=False, padding=2)
            self.vbox.pack_start(self.device_size, expand=False, fill=False, padding=2)

            button = self.add_button("Cancel", gtk.RESPONSE_NO)
            HobAltButton.style_button(button)
            button = self.add_button("Deploy image", gtk.RESPONSE_YES)
            tooltip = "Burn your image to an external storage device"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)

        self.vbox.show_all()
        self.progress_bar.hide()

    def popen_read(self, cmd):
        tmpout, errors = bb.process.run("%s" % cmd)
        return tmpout.strip()

    def find_all_external_devices(self):
        devices = glob.glob('/dev/disk/by-id/usb*')
        devices.extend(glob.glob('/dev/disk/by-id/mmc*'))
        ext_devs = [ os.readlink(u)
            for u in devices
            if not re.search(r'part\d+', u) ]
        return [ '%s' % u[u.rfind('/')+1:] for u in ext_devs ]

    def get_vendor_info(self, dev):
        try:
            return "%s" % self.popen_read('/sys/class/block/%s/device/vendor' % dev)
        except bb.process.ExecutionError:
            return ''

    def get_model_info(self, dev):
        try:
            return "%s" % self.popen_read('cat /sys/class/block/%s/device/model' % dev)
        except bb.process.ExecutionError:
            try:
                return "%s" % self.popen_read('cat /sys/class/block/%s/device/name' % dev)
            except bb.process.ExecutionError:
                return ''

    def get_size_info(self, dev):
        return "%s" % self.popen_read('cat /sys/class/block/%s/size' % dev)

    def select_image_button_clicked_cb(self, button):
        self.emit('select_image_clicked')

    def usb_combo_changed_cb(self, usb_combo):
        combo_item = self.usb_combo.get_active_text()
        vendor = self.get_vendor_info(combo_item.lstrip("/dev/"))
        if vendor is None:
            vendor = "Not known"
        markup = "<span font_desc='12'>Vendor: %s</span>" % vendor
        self.device_vendor.set_markup(markup)
        model = self.get_model_info(combo_item.lstrip("/dev/"))
        if model is None:
            model = "Not known"
        markup = "<span font_desc='12'>Model: %s</span>" % model
        self.device_model.set_markup(markup)
        size = float(self.get_size_info(combo_item.lstrip("/dev/"))) * 512 / 1024 / 1024
        if size > 1024:
            size = size/1024
            markup = "<span font_desc='12'>Size: %.2f GB</span>" % size
        else:
            markup = "<span font_desc='12'>Size: %.2f MB</span>" % size
        self.device_size.set_markup(markup)

    def response_cb(self, dialog, response_id):
        if response_id == gtk.RESPONSE_YES:
            lbl = ''
            dialogtype = gtk.STOCK_DIALOG_INFO
            if len(self.devices) == 1:
                item = "/dev/" + str(self.devices[0])
            else:
                item = self.usb_combo.get_active_text()
            if item and self.image:
                cmdline = bb.ui.crumbs.utils.which_terminal()

                f = tempfile.NamedTemporaryFile(delete=False)
                resultfn = f.name
                f.close()

                logpath = os.path.join(self.builder.parameters.tmpdir, 'log', 'hob-iot')
                bb.utils.mkdirhier(logpath)
                logfn = os.path.join(logpath, 'deploy-%s-%d.log' % (os.path.basename(item), int(time.time())))

                outimage = ''

                if cmdline:
                    cmdline += "\"source " + self.builder.parameters.core_base +"/iot-devkit-init-build-env " + \
                                self.builder.parameters.build_dir + \
                                " && { printf '\nCreating an image suitable for the device using wic:\n'" + \
                                " ; export PYTHONUNBUFFERED=1 " + \
                                " ; wic create iot-devkit " + \
                                " -r " + self.builder.parameters.tmpdir + "/work/clanton-poky-linux/" + self.image + "/1.0-r0/rootfs" + \
                                " -k " + self.builder.parameters.staging_kernel_dir + \
                                " -n " + self.builder.parameters.staging_dir_native + \
                                " -b " + self.builder.parameters.image_addr + \
                                " 2>&1 ; echo $? > " + resultfn + " ; } | tee " + logfn + "\""

                    dialog.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
                    bb.ui.crumbs.utils.wait(0.1)
                    subprocess.call(shlex.split(cmdline))

                    with open(logfn, 'r') as f:
                        output = f.read()

                    with open(resultfn, 'r') as f:
                        result = f.readline().strip()
                        if result != '0':
                            lbl = "<b>Failed to create final image to deploy:</b>\n\n%s" % glib.markup_escape_text(output)
                            dialogtype = gtk.STOCK_DIALOG_ERROR
                        else:
                            for line in output.splitlines():
                                if '.direct' in line:
                                    outimage = line.strip()
                                    break

                    with open(logfn, 'a') as f:
                        f.write('\n\nwic command was:\n%s\n' % cmdline)

                    if not outimage:
                        lbl = "<b>Unable to determine output image from wic output:</b>\n\n%s" % glib.markup_escape_text(output)
                        dialogtype = gtk.STOCK_DIALOG_ERROR
                else:
                    lbl = "<b>Failed to find terminal to run</b>"
                    dialogtype = gtk.STOCK_DIALOG_ERROR

                if not lbl:
                    cmdline = bb.ui.crumbs.utils.which_terminal()
                    if cmdline:
                        tmpfile = tempfile.NamedTemporaryFile()
                        cmdline += "\"printf 'Writing final image:\n  " + outimage + "\nto storage device:\n  " + item + \
                                    "\n\n(This requires elevated privileges - you may be prompted for your password.)\n\n'" + \
                                    " ; sudo dd if=" + outimage + " of=" + item + "; echo $? > " + tmpfile.name + "\""
                        subprocess.call(shlex.split(cmdline))
                        dialog.window.set_cursor(None)

                        result = tmpfile.readline().strip()

                        if result == '0':
                            lbl = "<b>Image deployed to external storage device</b>"
                        elif not result:
                            lbl = "<b>Image writing cancelled</b>"
                            dialogtype = gtk.STOCK_DIALOG_WARNING
                        else:
                            lbl = "<b>Failed to deploy image.</b>\nPlease check image <b>%s</b> exists and storage device <b>%s</b> is writable." % (self.image, item)
                            dialogtype = gtk.STOCK_DIALOG_ERROR
                        tmpfile.close()
            if len(lbl):
                crumbs_dialog = CrumbsMessageDialog(self, lbl, dialogtype)
                button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK)
                HobButton.style_button(button)
                crumbs_dialog.run()
                crumbs_dialog.destroy()

    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 write_file(self, ifile, ofile):
        self.progress_bar.reset()
        self.progress_bar.show()

        f_from = os.open(ifile, os.O_RDONLY)
        f_to = os.open(ofile, os.O_WRONLY)

        total_size = os.stat(ifile).st_size
        written_size = 0

        while True:
            buf = os.read(f_from, 1024*1024)
            if not buf:
                break
            os.write(f_to, buf)
            written_size += 1024*1024
            self.update_progress_bar("Writing to usb:", written_size * 1.0/total_size)

        self.update_progress_bar("Writing completed:", 1.0)
        os.close(f_from)
        os.close(f_to)
        self.progress_bar.hide()
コード例 #23
0
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)
コード例 #24
0
class ImageConfigurationPage (HobPage):

    __dummy_machine__ = "--select a machine--"
    __dummy_image__   = "--select a base image--"

    def __init__(self, builder):
        super(ImageConfigurationPage, self).__init__(builder, "Image configuration")

        self.image_combo_id = None
        # we use machine_combo_changed_by_manual to identify the machine is changed by code
        # or by manual. If by manual, all user's recipe selection and package selection are
        # cleared.
        self.machine_combo_changed_by_manual = True
        self.stopping = False
        self.create_visual_elements()

    def create_visual_elements(self):
        # create visual elements
        self.toolbar = gtk.Toolbar()
        self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL)
        self.toolbar.set_style(gtk.TOOLBAR_BOTH)

        template_button = self.append_toolbar_button(self.toolbar,
            "Templates",
            hic.ICON_TEMPLATES_DISPLAY_FILE,
            hic.ICON_TEMPLATES_HOVER_FILE,
            "Load a previously saved template",
            self.template_button_clicked_cb)
        my_images_button = self.append_toolbar_button(self.toolbar,
            "Images",
            hic.ICON_IMAGES_DISPLAY_FILE,
            hic.ICON_IMAGES_HOVER_FILE,
            "Open previously built images",
            self.my_images_button_clicked_cb)
        settings_button = self.append_toolbar_button(self.toolbar,
            "Settings",
            hic.ICON_SETTINGS_DISPLAY_FILE,
            hic.ICON_SETTINGS_HOVER_FILE,
            "View additional build settings",
            self.settings_button_clicked_cb)

        self.config_top_button = self.add_onto_top_bar(self.toolbar)

        self.gtable = gtk.Table(40, 40, True)
        self.create_config_machine()
        self.create_config_baseimg()
        self.config_build_button = self.create_config_build_button()

    def _remove_all_widget(self):
        children = self.gtable.get_children() or []
        for child in children:
            self.gtable.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 _pack_components(self, pack_config_build_button = False):
        self._remove_all_widget()
        self.pack_start(self.config_top_button, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        self.box_group_area.pack_start(self.gtable, expand=True, fill=True)
        if pack_config_build_button:
            self.box_group_area.pack_end(self.config_build_button, expand=False, fill=False)
        else:
            box = gtk.HBox(False, 6)
            box.show()
            subbox = gtk.HBox(False, 0)
            subbox.set_size_request(205, 49)
            subbox.show()
            box.add(subbox)
            self.box_group_area.pack_end(box, False, False)

    def show_machine(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button = False)
        self.set_config_machine_layout(show_progress_bar = False)
        self.show_all()

    def update_progress_bar(self, title, fraction, status=None):
        if self.stopping == False:
            self.progress_bar.update(fraction)
            self.progress_bar.set_text(title)
            self.progress_bar.set_rcstyle(status)

    def show_info_populating(self):
        self._pack_components(pack_config_build_button = False)
        self.set_config_machine_layout(show_progress_bar = True)
        self.show_all()

    def show_info_populated(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button = False)
        self.set_config_machine_layout(show_progress_bar = False)
        self.set_config_baseimg_layout()
        self.show_all()

    def show_baseimg_selected(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button = True)
        self.set_config_machine_layout(show_progress_bar = False)
        self.set_config_baseimg_layout()
        self.show_all()
        if self.builder.recipe_model.get_selected_image() == self.builder.recipe_model.__custom_image__:
            self.just_bake_button.hide()

    def create_config_machine(self):
        self.machine_title = gtk.Label()
        self.machine_title.set_alignment(0.0, 0.5)
        mark = "<span %s>Select a machine</span>" % self.span_tag('x-large', 'bold')
        self.machine_title.set_markup(mark)

        self.machine_title_desc = gtk.Label()
        self.machine_title_desc.set_alignment(0.0, 0.5)
        mark = ("<span %s>Your selection is the profile of the target machine for which you"
        " are building the image.\n</span>") % (self.span_tag('medium'))
        self.machine_title_desc.set_markup(mark)

        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.connect("changed", self.machine_combo_changed_cb)

        icon_file = hic.ICON_LAYERS_DISPLAY_FILE
        hover_file = hic.ICON_LAYERS_HOVER_FILE
        self.layer_button = HobImageButton("Layers", "Add support for machines, software, etc.",
                                icon_file, hover_file)
        self.layer_button.connect("clicked", self.layer_button_clicked_cb)

        markup = "Layers are a powerful mechanism to extend the Yocto Project "
        markup += "with your own functionality.\n"
        markup += "For more on layers, check the <a href=\""
        markup += "http://www.yoctoproject.org/docs/current/dev-manual/"
        markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>."
        self.layer_info_icon = HobInfoButton(markup, self.get_parent())

#        self.progress_box = gtk.HBox(False, 6)
        self.progress_bar = HobProgressBar()
#        self.progress_box.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.progress_box.pack_end(stop_button, expand=False, fill=False)
        self.machine_separator = gtk.HSeparator()

    def set_config_machine_layout(self, show_progress_bar = False):
        self.gtable.attach(self.machine_title, 0, 40, 0, 4)
        self.gtable.attach(self.machine_title_desc, 0, 40, 4, 6)
        self.gtable.attach(self.machine_combo, 0, 12, 7, 10)
        self.gtable.attach(self.layer_button, 14, 36, 7, 12)
        self.gtable.attach(self.layer_info_icon, 36, 40, 7, 11)
        if show_progress_bar:
            #self.gtable.attach(self.progress_box, 0, 40, 15, 18)
            self.gtable.attach(self.progress_bar, 0, 37, 15, 18)
            self.gtable.attach(self.stop_button, 37, 40, 15, 18, 0, 0)
        self.gtable.attach(self.machine_separator, 0, 40, 13, 14)

    def create_config_baseimg(self):
        self.image_title = gtk.Label()
        self.image_title.set_alignment(0, 1.0)
        mark = "<span %s>Select a base image</span>" % self.span_tag('x-large', 'bold')
        self.image_title.set_markup(mark)

        self.image_title_desc = gtk.Label()
        self.image_title_desc.set_alignment(0, 0.5)
        mark = ("<span %s>Base images are a starting point for the type of image you want. "
                "You can build them as \n"
                "they are or customize them to your specific needs.\n</span>") % self.span_tag('medium')
        self.image_title_desc.set_markup(mark)

        self.image_combo = gtk.combo_box_new_text()
        self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb)

        self.image_desc = gtk.Label()
        self.image_desc.set_alignment(0.0, 0.5)
        self.image_desc.set_size_request(256, -1)
        self.image_desc.set_justify(gtk.JUSTIFY_LEFT)
        self.image_desc.set_line_wrap(True)

        # button to view recipes
        icon_file = hic.ICON_RCIPE_DISPLAY_FILE
        hover_file = hic.ICON_RCIPE_HOVER_FILE
        self.view_adv_configuration_button = HobImageButton("Advanced configuration",
                                                                 "Select image types, package formats, etc",
                                                                 icon_file, hover_file)        
        self.view_adv_configuration_button.connect("clicked", self.view_adv_configuration_button_clicked_cb)

        self.image_separator = gtk.HSeparator()

    def set_config_baseimg_layout(self):
        self.gtable.attach(self.image_title, 0, 40, 15, 17)
        self.gtable.attach(self.image_title_desc, 0, 40, 18, 22)
        self.gtable.attach(self.image_combo, 0, 12, 23, 26)
        self.gtable.attach(self.image_desc, 0, 12, 27, 33)
        self.gtable.attach(self.view_adv_configuration_button, 14, 36, 23, 28)
        self.gtable.attach(self.image_separator, 0, 40, 35, 36)

    def create_config_build_button(self):
        # Create the "Build packages" and "Build image" buttons at the bottom
        button_box = gtk.HBox(False, 6)

        # create button "Build image"
        self.just_bake_button = HobButton("Build image")
        #self.just_bake_button.set_size_request(205, 49)
        self.just_bake_button.set_tooltip_text("Build target image")
        self.just_bake_button.connect("clicked", self.just_bake_button_clicked_cb)
        button_box.pack_end(self.just_bake_button, expand=False, fill=False)

        # create button "Edit Image"
        self.edit_image_button = HobAltButton("Edit image")
        #self.edit_image_button.set_size_request(205, 49)
        self.edit_image_button.set_tooltip_text("Edit target image")
        self.edit_image_button.connect("clicked", self.edit_image_button_clicked_cb)
        button_box.pack_end(self.edit_image_button, expand=False, fill=False)

        return button_box

    def stop_button_clicked_cb(self, button):
        self.stopping = True
        self.progress_bar.set_text("Stopping recipe parsing")
        self.progress_bar.set_rcstyle("stop")
        self.builder.cancel_parse_sync()

    def machine_combo_changed_cb(self, machine_combo):
        self.stopping = False
        combo_item = machine_combo.get_active_text()
        if not combo_item or combo_item == self.__dummy_machine__:
            return

        # remove __dummy_machine__ item from the store list after first user selection
        # because it is no longer valid
        combo_store = machine_combo.get_model()
        if len(combo_store) and (combo_store[0][0] == self.__dummy_machine__):
            machine_combo.remove_text(0)

        self.builder.configuration.curr_mach = combo_item
        if self.machine_combo_changed_by_manual:
            self.builder.configuration.clear_selection()
        # reset machine_combo_changed_by_manual
        self.machine_combo_changed_by_manual = True

        # Do reparse recipes
        self.builder.populate_recipe_package_info_async()

    def update_machine_combo(self):
        all_machines = [self.__dummy_machine__] + self.builder.parameters.all_machines

        model = self.machine_combo.get_model()
        model.clear()
        for machine in all_machines:
            self.machine_combo.append_text(machine)
        self.machine_combo.set_active(0)

    def switch_machine_combo(self):
        self.machine_combo_changed_by_manual = False
        model = self.machine_combo.get_model()
        active = 0
        while active < len(model):
            if model[active][0] == self.builder.configuration.curr_mach:
                self.machine_combo.set_active(active)
                return
            active += 1

        if model[0][0] != self.__dummy_machine__:
            self.machine_combo.insert_text(0, self.__dummy_machine__)

        self.machine_combo.set_active(0)

    def update_image_desc(self):
        desc = ""
        selected_image = self.image_combo.get_active_text()
        if selected_image and selected_image in self.builder.recipe_model.pn_path.keys():
            image_path = self.builder.recipe_model.pn_path[selected_image]
            image_iter = self.builder.recipe_model.get_iter(image_path)
            desc = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_DESC)

        mark = ("<span %s>%s</span>\n") % (self.span_tag('small'), desc)
        self.image_desc.set_markup(mark)

    def image_combo_changed_idle_cb(self, selected_image, selected_recipes, selected_packages):
        self.builder.update_recipe_model(selected_image, selected_recipes)
        self.builder.update_package_model(selected_packages)
        self.builder.window_sensitive(True)

    def image_combo_changed_cb(self, combo):
        self.builder.window_sensitive(False)
        selected_image = self.image_combo.get_active_text()
        if not selected_image or (selected_image == self.__dummy_image__):
            return

        # remove __dummy_image__ item from the store list after first user selection
        # because it is no longer valid
        combo_store = combo.get_model()
        if len(combo_store) and (combo_store[0][0] == self.__dummy_image__):
            combo.remove_text(0)

        self.builder.customized = False

        selected_recipes = []

        image_path = self.builder.recipe_model.pn_path[selected_image]
        image_iter = self.builder.recipe_model.get_iter(image_path)
        selected_packages = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_INSTALL).split()
        self.update_image_desc()

        self.builder.recipe_model.reset()
        self.builder.package_model.reset()

        self.show_baseimg_selected()

        if selected_image == self.builder.recipe_model.__custom_image__:
            self.just_bake_button.hide()

        glib.idle_add(self.image_combo_changed_idle_cb, selected_image, selected_recipes, selected_packages)

    def _image_combo_connect_signal(self):
        if not self.image_combo_id:
            self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb)

    def _image_combo_disconnect_signal(self):
        if self.image_combo_id:
            self.image_combo.disconnect(self.image_combo_id)
            self.image_combo_id = None

    def update_image_combo(self, recipe_model, selected_image):
        # Update the image combo according to the images in the recipe_model
        # populate image combo
        filter = {RecipeListModel.COL_TYPE : ['image']}
        image_model = recipe_model.tree_model(filter)
        image_model.set_sort_column_id(recipe_model.COL_NAME, gtk.SORT_ASCENDING)
        active = 0
        cnt = 1

        white_pattern = []
        if self.builder.parameters.image_white_pattern:
            for i in self.builder.parameters.image_white_pattern.split():
                white_pattern.append(re.compile(i))

        black_pattern = []
        if self.builder.parameters.image_black_pattern:
            for i in self.builder.parameters.image_black_pattern.split():
                black_pattern.append(re.compile(i))
        black_pattern.append(re.compile("hob-image"))

        it = image_model.get_iter_first()
        self._image_combo_disconnect_signal()
        model = self.image_combo.get_model()
        model.clear()
        # Set a indicator text to combo store when first open
        self.image_combo.append_text(self.__dummy_image__)
        # append and set active
        while it:
            path = image_model.get_path(it)
            it = image_model.iter_next(it)
            image_name = image_model[path][recipe_model.COL_NAME]
            if image_name == self.builder.recipe_model.__custom_image__:
                continue

            if black_pattern:
                allow = True
                for pattern in black_pattern:
                    if pattern.search(image_name):
                        allow = False
                        break
            elif white_pattern:
                allow = False
                for pattern in white_pattern:
                    if pattern.search(image_name):
                        allow = True
                        break
            else:
                allow = True

            if allow:
                self.image_combo.append_text(image_name)
                if image_name == selected_image:
                    active = cnt
                cnt = cnt + 1

        self.image_combo.append_text(self.builder.recipe_model.__custom_image__)
        if selected_image == self.builder.recipe_model.__custom_image__:
            active = cnt

        self.image_combo.set_active(active)

        if active != 0:
            self.show_baseimg_selected()

        self._image_combo_connect_signal()

    def layer_button_clicked_cb(self, button):
        # Create a layer selection dialog
        self.builder.show_layer_selection_dialog()
        
    def view_adv_configuration_button_clicked_cb(self, button):
        # Create an advanced settings dialog
        response, settings_changed = self.builder.show_adv_settings_dialog()
        if not response:
            return
        if settings_changed:
            self.builder.reparse_post_adv_settings()        

    def just_bake_button_clicked_cb(self, button):
        self.builder.just_bake()

    def edit_image_button_clicked_cb(self, button):
        self.builder.configuration.initial_selected_image = self.builder.configuration.selected_image
        self.builder.show_recipes()

    def template_button_clicked_cb(self, button):
        response, path = self.builder.show_load_template_dialog()
        if not response:
            return
        if path:
            self.builder.load_template(path)

    def my_images_button_clicked_cb(self, button):
        self.builder.show_load_my_images_dialog()

    def settings_button_clicked_cb(self, button):
        # Create an advanced settings dialog
        response, settings_changed = self.builder.show_simple_settings_dialog()
        if not response:
            return
        if settings_changed:
            self.builder.reparse_post_adv_settings()
コード例 #25
0
class ImageConfigurationPage (HobPage):

    __dummy_machine__ = "--select a machine--"
    __dummy_image__   = "--select an image recipe--"
    __custom_image__  = "Select from my image recipes"

    def __init__(self, builder):
        super(ImageConfigurationPage, self).__init__(builder, "Image configuration")

        self.image_combo_id = None
        # we use machine_combo_changed_by_manual to identify the machine is changed by code
        # or by manual. If by manual, all user's recipe selection and package selection are
        # cleared.
        self.machine_combo_changed_by_manual = True
        self.stopping = False
        self.warning_shift = 0
        self.custom_image_selected = None
        self.create_visual_elements()

    def create_visual_elements(self):
        # create visual elements
        self.toolbar = gtk.Toolbar()
        self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL)
        self.toolbar.set_style(gtk.TOOLBAR_BOTH)

        my_images_button = self.append_toolbar_button(self.toolbar,
            "Images",
            hic.ICON_IMAGES_DISPLAY_FILE,
            hic.ICON_IMAGES_HOVER_FILE,
            "Open previously built images",
            self.my_images_button_clicked_cb)
        settings_button = self.append_toolbar_button(self.toolbar,
            "Settings",
            hic.ICON_SETTINGS_DISPLAY_FILE,
            hic.ICON_SETTINGS_HOVER_FILE,
            "View additional build settings",
            self.settings_button_clicked_cb)

        self.config_top_button = self.add_onto_top_bar(self.toolbar)

        self.gtable = gtk.Table(40, 40, True)
        self.create_config_machine()
        self.create_config_baseimg()
        self.config_build_button = self.create_config_build_button()

    def _remove_all_widget(self):
        children = self.gtable.get_children() or []
        for child in children:
            self.gtable.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 _pack_components(self, pack_config_build_button = False):
        self._remove_all_widget()
        self.pack_start(self.config_top_button, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        self.box_group_area.pack_start(self.gtable, expand=True, fill=True)
        if pack_config_build_button:
            self.box_group_area.pack_end(self.config_build_button, expand=False, fill=False)
        else:
            box = gtk.HBox(False, 6)
            box.show()
            subbox = gtk.HBox(False, 0)
            subbox.set_size_request(205, 49)
            subbox.show()
            box.add(subbox)
            self.box_group_area.pack_end(box, False, False)

    def show_machine(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button = False)
        self.set_config_machine_layout(show_progress_bar = False)
        self.show_all()

    def update_progress_bar(self, title, fraction, status=None):
        if self.stopping == False:
            self.progress_bar.update(fraction)
            self.progress_bar.set_text(title)
            self.progress_bar.set_rcstyle(status)

    def show_info_populating(self):
        self._pack_components(pack_config_build_button = False)
        self.set_config_machine_layout(show_progress_bar = True)
        self.show_all()

    def show_info_populated(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button = False)
        self.set_config_machine_layout(show_progress_bar = False)
        self.set_config_baseimg_layout()
        self.show_all()

    def show_baseimg_selected(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button = True)
        self.set_config_machine_layout(show_progress_bar = False)
        self.set_config_baseimg_layout()
        self.show_all()
        if self.builder.recipe_model.get_selected_image() == self.builder.recipe_model.__custom_image__:
            self.just_bake_button.hide()

    def add_warnings_bar(self):
        #create the warnings bar shown when recipes parsing generates warnings
        color = HobColors.KHAKI
        warnings_bar = gtk.EventBox()
        warnings_bar.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
        warnings_bar.set_flags(gtk.CAN_DEFAULT)
        warnings_bar.grab_default()

        build_stop_tab = gtk.Table(10, 20, True)
        warnings_bar.add(build_stop_tab)

        icon = gtk.Image()
        icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ALERT_FILE)
        icon.set_from_pixbuf(icon_pix_buffer)
        build_stop_tab.attach(icon, 0, 2, 0, 10)

        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        warnings_nb = len(self.builder.parsing_warnings)
        if warnings_nb == 1:
            label.set_markup("<span size='x-large'><b>1 recipe parsing warning</b></span>")
        else:
            label.set_markup("<span size='x-large'><b>%s recipe parsing warnings</b></span>" % warnings_nb)
        build_stop_tab.attach(label, 2, 12, 0, 10)

        view_warnings_button = HobButton("View warnings")
        view_warnings_button.connect('clicked', self.view_warnings_button_clicked_cb)
        build_stop_tab.attach(view_warnings_button, 15, 19, 1, 9)

        return warnings_bar

    def disable_warnings_bar(self):
        if self.builder.parsing_warnings:
            if hasattr(self, 'warnings_bar'):
                self.warnings_bar.hide_all()
            self.builder.parsing_warnings = []

    def create_config_machine(self):
        self.machine_title = gtk.Label()
        self.machine_title.set_alignment(0.0, 0.5)
        mark = "<span %s>Select a machine</span>" % self.span_tag('x-large', 'bold')
        self.machine_title.set_markup(mark)

        self.machine_title_desc = gtk.Label()
        self.machine_title_desc.set_alignment(0.0, 0.5)
        mark = ("<span %s>Your selection is the profile of the target machine for which you"
        " are building the image.\n</span>") % (self.span_tag('medium'))
        self.machine_title_desc.set_markup(mark)

        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.connect("changed", self.machine_combo_changed_cb)

        icon_file = hic.ICON_LAYERS_DISPLAY_FILE
        hover_file = hic.ICON_LAYERS_HOVER_FILE
        self.layer_button = HobImageButton("Layers", "Add support for machines, software, etc.",
                                icon_file, hover_file)
        self.layer_button.connect("clicked", self.layer_button_clicked_cb)

        markup = "Layers are a powerful mechanism to extend the Yocto Project "
        markup += "with your own functionality.\n"
        markup += "For more on layers, check the <a href=\""
        markup += "http://www.yoctoproject.org/docs/current/dev-manual/"
        markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>."
        self.layer_info_icon = HobInfoButton("<b>Layers</b>" + "*" + markup, self.get_parent())
        self.progress_bar = HobProgressBar()
        self.stop_button = HobAltButton("Stop")
        self.stop_button.connect("clicked", self.stop_button_clicked_cb)
        self.machine_separator = gtk.HSeparator()

    def set_config_machine_layout(self, show_progress_bar = False):
        self.gtable.attach(self.machine_title, 0, 40, 0, 4)
        self.gtable.attach(self.machine_title_desc, 0, 40, 4, 6)
        self.gtable.attach(self.machine_combo, 0, 12, 7, 10)
        self.gtable.attach(self.layer_button, 14, 36, 7, 12)
        self.gtable.attach(self.layer_info_icon, 36, 40, 7, 11)
        if show_progress_bar:
            #self.gtable.attach(self.progress_box, 0, 40, 15, 18)
            self.gtable.attach(self.progress_bar, 0, 37, 15, 18)
            self.gtable.attach(self.stop_button, 37, 40, 15, 18, 0, 0)
        if self.builder.parsing_warnings:
            self.warnings_bar = self.add_warnings_bar()
            self.gtable.attach(self.warnings_bar, 0, 40, 14, 18)
            self.warning_shift = 4
        else:
            self.warning_shift = 0
        self.gtable.attach(self.machine_separator, 0, 40, 13, 14)

    def create_config_baseimg(self):
        self.image_title = gtk.Label()
        self.image_title.set_alignment(0, 1.0)
        mark = "<span %s>Select an image recipe</span>" % self.span_tag('x-large', 'bold')
        self.image_title.set_markup(mark)

        self.image_title_desc = gtk.Label()
        self.image_title_desc.set_alignment(0, 0.5)

        mark = ("<span %s>Image recipes are a starting point for the type of image you want. "
                "You can build them as \n"
                "they are or edit them to suit your needs.\n</span>") % self.span_tag('medium')
        self.image_title_desc.set_markup(mark)

        self.image_combo = gtk.combo_box_new_text()
        self.image_combo.set_row_separator_func(self.combo_separator_func, None)
        self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb)

        self.image_desc = gtk.Label()
        self.image_desc.set_alignment(0.0, 0.5)
        self.image_desc.set_size_request(256, -1)
        self.image_desc.set_justify(gtk.JUSTIFY_LEFT)
        self.image_desc.set_line_wrap(True)

        # button to view recipes
        icon_file = hic.ICON_RCIPE_DISPLAY_FILE
        hover_file = hic.ICON_RCIPE_HOVER_FILE
        self.view_adv_configuration_button = HobImageButton("Advanced configuration",
                                                                 "Select image types, package formats, etc",
                                                                 icon_file, hover_file)        
        self.view_adv_configuration_button.connect("clicked", self.view_adv_configuration_button_clicked_cb)

        self.image_separator = gtk.HSeparator()

    def combo_separator_func(self, model, iter, user_data):
        name = model.get_value(iter, 0)
        if name == "--Separator--":
            return True

    def set_config_baseimg_layout(self):
        self.gtable.attach(self.image_title, 0, 40, 15+self.warning_shift, 17+self.warning_shift)
        self.gtable.attach(self.image_title_desc, 0, 40, 18+self.warning_shift, 22+self.warning_shift)
        self.gtable.attach(self.image_combo, 0, 12, 23+self.warning_shift, 26+self.warning_shift)
        self.gtable.attach(self.image_desc, 0, 12, 27+self.warning_shift, 33+self.warning_shift)
        self.gtable.attach(self.view_adv_configuration_button, 14, 36, 23+self.warning_shift, 28+self.warning_shift)
        self.gtable.attach(self.image_separator, 0, 40, 35+self.warning_shift, 36+self.warning_shift)

    def create_config_build_button(self):
        # Create the "Build packages" and "Build image" buttons at the bottom
        button_box = gtk.HBox(False, 6)

        # create button "Build image"
        self.just_bake_button = HobButton("Build image")
        self.just_bake_button.set_tooltip_text("Build the image recipe as it is")
        self.just_bake_button.connect("clicked", self.just_bake_button_clicked_cb)
        button_box.pack_end(self.just_bake_button, expand=False, fill=False)

        # create button "Edit image recipe"
        self.edit_image_button = HobAltButton("Edit image recipe")
        self.edit_image_button.set_tooltip_text("Customize the recipes and packages to be included in your image")
        self.edit_image_button.connect("clicked", self.edit_image_button_clicked_cb)
        button_box.pack_end(self.edit_image_button, expand=False, fill=False)

        return button_box

    def stop_button_clicked_cb(self, button):
        self.stopping = True
        self.progress_bar.set_text("Stopping recipe parsing")
        self.progress_bar.set_rcstyle("stop")
        self.builder.cancel_parse_sync()

    def view_warnings_button_clicked_cb(self, button):
        self.builder.show_warning_dialog()

    def machine_combo_changed_idle_cb(self):
        self.builder.window.set_cursor(None)

    def machine_combo_changed_cb(self, machine_combo):
        self.builder.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
        self.builder.wait(0.1) #wait for combo and cursor to update
        self.stopping = False
        self.builder.parsing_warnings = []
        combo_item = machine_combo.get_active_text()
        if not combo_item or combo_item == self.__dummy_machine__:
            return

        # remove __dummy_machine__ item from the store list after first user selection
        # because it is no longer valid
        combo_store = machine_combo.get_model()
        if len(combo_store) and (combo_store[0][0] == self.__dummy_machine__):
            machine_combo.remove_text(0)

        self.builder.configuration.curr_mach = combo_item
        if self.machine_combo_changed_by_manual:
            self.builder.configuration.clear_selection()
        # reset machine_combo_changed_by_manual
        self.machine_combo_changed_by_manual = True

        self.builder.configuration.selected_image = None

        # Do reparse recipes
        self.builder.populate_recipe_package_info_async()

        glib.idle_add(self.machine_combo_changed_idle_cb)

    def update_machine_combo(self):
        self.disable_warnings_bar()
        all_machines = [self.__dummy_machine__] + self.builder.parameters.all_machines

        model = self.machine_combo.get_model()
        model.clear()
        for machine in all_machines:
            self.machine_combo.append_text(machine)
        self.machine_combo.set_active(0)

    def switch_machine_combo(self):
        self.disable_warnings_bar()
        self.machine_combo_changed_by_manual = False
        model = self.machine_combo.get_model()
        active = 0
        while active < len(model):
            if model[active][0] == self.builder.configuration.curr_mach:
                self.machine_combo.set_active(active)
                return
            active += 1

        if model[0][0] != self.__dummy_machine__:
            self.machine_combo.insert_text(0, self.__dummy_machine__)

        self.machine_combo.set_active(0)

    def update_image_desc(self):
        desc = ""
        selected_image = self.image_combo.get_active_text()
        if selected_image and selected_image in self.builder.recipe_model.pn_path.keys():
            image_path = self.builder.recipe_model.pn_path[selected_image]
            image_iter = self.builder.recipe_model.get_iter(image_path)
            desc = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_DESC)

        mark = ("<span %s>%s</span>\n") % (self.span_tag('small'), desc)
        self.image_desc.set_markup(mark)

    def image_combo_changed_idle_cb(self, selected_image, selected_recipes, selected_packages):
        self.builder.update_recipe_model(selected_image, selected_recipes)
        self.builder.update_package_model(selected_packages)
        self.builder.window_sensitive(True)

    def image_combo_changed_cb(self, combo):
        self.builder.window_sensitive(False)
        selected_image = self.image_combo.get_active_text()
        if selected_image == self.__custom_image__:
            topdir = self.builder.get_topdir()
            images_dir = topdir + "/recipes/images/"
            self.builder.ensure_dir(images_dir)

            dialog = RetrieveImageDialog(images_dir, "Select from my image recipes",
                            self.builder, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
            response = dialog.run()
            if response == gtk.RESPONSE_OK:
                image_name = dialog.get_filename()
                head, tail = os.path.split(image_name)
                selected_image = os.path.splitext(tail)[0]
                self.custom_image_selected = selected_image
                self.update_image_combo(self.builder.recipe_model, selected_image)
            else:
                selected_image = self.__dummy_image__
                self.update_image_combo(self.builder.recipe_model, None)
            dialog.destroy()
        else:
            if self.custom_image_selected:
                self.custom_image_selected = None
                self.update_image_combo(self.builder.recipe_model, selected_image)

        if not selected_image or (selected_image == self.__dummy_image__):
            self.builder.window_sensitive(True)
            self.just_bake_button.hide()
            self.edit_image_button.hide()
            return

        # remove __dummy_image__ item from the store list after first user selection
        # because it is no longer valid
        combo_store = combo.get_model()
        if len(combo_store) and (combo_store[0][0] == self.__dummy_image__):
            combo.remove_text(0)

        self.builder.customized = False

        selected_recipes = []

        image_path = self.builder.recipe_model.pn_path[selected_image]
        image_iter = self.builder.recipe_model.get_iter(image_path)
        selected_packages = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_INSTALL).split()
        self.update_image_desc()

        self.builder.recipe_model.reset()
        self.builder.package_model.reset()

        self.show_baseimg_selected()

        if selected_image == self.builder.recipe_model.__custom_image__:
            self.just_bake_button.hide()

        glib.idle_add(self.image_combo_changed_idle_cb, selected_image, selected_recipes, selected_packages)

    def _image_combo_connect_signal(self):
        if not self.image_combo_id:
            self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb)

    def _image_combo_disconnect_signal(self):
        if self.image_combo_id:
            self.image_combo.disconnect(self.image_combo_id)
            self.image_combo_id = None

    def update_image_combo(self, recipe_model, selected_image):
        # Update the image combo according to the images in the recipe_model
        # populate image combo
        filter = {RecipeListModel.COL_TYPE : ['image']}
        image_model = recipe_model.tree_model(filter)
        image_model.set_sort_column_id(recipe_model.COL_NAME, gtk.SORT_ASCENDING)
        active = 0
        cnt = 0

        white_pattern = []
        if self.builder.parameters.image_white_pattern:
            for i in self.builder.parameters.image_white_pattern.split():
                white_pattern.append(re.compile(i))

        black_pattern = []
        if self.builder.parameters.image_black_pattern:
            for i in self.builder.parameters.image_black_pattern.split():
                black_pattern.append(re.compile(i))
        black_pattern.append(re.compile("hob-image"))

        it = image_model.get_iter_first()
        self._image_combo_disconnect_signal()
        model = self.image_combo.get_model()
        model.clear()
        # Set a indicator text to combo store when first open
        if not selected_image:
            self.image_combo.append_text(self.__dummy_image__)
            cnt = cnt + 1

        self.image_combo.append_text(self.__custom_image__)
        self.image_combo.append_text("--Separator--")
        cnt = cnt + 2

        topdir = self.builder.get_topdir()
        # append and set active
        while it:
            path = image_model.get_path(it)
            it = image_model.iter_next(it)
            image_name = image_model[path][recipe_model.COL_NAME]
            if image_name == self.builder.recipe_model.__custom_image__:
                continue

            if black_pattern:
                allow = True
                for pattern in black_pattern:
                    if pattern.search(image_name):
                        allow = False
                        break
            elif white_pattern:
                allow = False
                for pattern in white_pattern:
                    if pattern.search(image_name):
                        allow = True
                        break
            else:
                allow = True

            file_name = image_model[path][recipe_model.COL_FILE]
            if file_name and topdir in file_name:
                allow = False

            if allow:
                self.image_combo.append_text(image_name)
                if image_name == selected_image:
                    active = cnt
                cnt = cnt + 1
        self.image_combo.append_text(self.builder.recipe_model.__custom_image__)

        if selected_image == self.builder.recipe_model.__custom_image__:
            active = cnt

        if self.custom_image_selected:
            self.image_combo.append_text("--Separator--")
            self.image_combo.append_text(self.custom_image_selected)
            cnt = cnt + 2
            if self.custom_image_selected == selected_image:
                active = cnt

        self.image_combo.set_active(active)

        if active != 0:
            self.show_baseimg_selected()

        self._image_combo_connect_signal()

    def layer_button_clicked_cb(self, button):
        # Create a layer selection dialog
        self.builder.show_layer_selection_dialog()

    def view_adv_configuration_button_clicked_cb(self, button):
        # Create an advanced settings dialog
        response, settings_changed = self.builder.show_adv_settings_dialog()
        if not response:
            return
        if settings_changed:
            self.builder.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
            self.builder.wait(0.1) #wait for adv_settings_dialog to terminate
            self.builder.reparse_post_adv_settings()
            self.builder.window.set_cursor(None)

    def just_bake_button_clicked_cb(self, button):
        self.builder.parsing_warnings = []
        self.builder.just_bake()

    def edit_image_button_clicked_cb(self, button):
        self.builder.configuration.initial_selected_image = self.builder.configuration.selected_image
        self.builder.show_recipes()

    def my_images_button_clicked_cb(self, button):
        self.builder.show_load_my_images_dialog()

    def settings_button_clicked_cb(self, button):
        # Create an advanced settings dialog
        response, settings_changed = self.builder.show_simple_settings_dialog()
        if not response:
            return
        if settings_changed:
            self.builder.reparse_post_adv_settings()
コード例 #26
0
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('&lt;&lt; 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")
コード例 #27
0
ファイル: depexp.py プロジェクト: andragabr/bitbake
def main(server, eventHandler, params):
    try:
        params.updateFromServer(server)
        cmdline = params.parseActions()
        if not cmdline:
            print("Nothing to do.  Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
            return 1
        if 'msg' in cmdline and cmdline['msg']:
            print(cmdline['msg'])
            return 1
        cmdline = cmdline['action']
        if not cmdline or cmdline[0] != "generateDotGraph":
            print("This UI requires the -g option")
            return 1
        ret, error = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]])
        if error:
            print("Error running command '%s': %s" % (cmdline, error))
            return 1
        elif ret != True:
            print("Error running command '%s': returned %s" % (cmdline, ret))
            return 1
    except xmlrpclib.Fault as x:
        print("XMLRPC Fault getting commandline:\n %s" % x)
        return

    shutdown = 0

    gtkgui = gtkthread(shutdown)
    gtkgui.start()

    gtk.gdk.threads_enter()
    dep = DepExplorer()
    bardialog = gtk.Dialog(parent=dep,
                           flags=gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT)
    bardialog.set_default_size(400, 50)
    pbar = HobProgressBar()
    bardialog.vbox.pack_start(pbar)
    bardialog.show_all()
    bardialog.connect("delete-event", gtk.main_quit)
    gtk.gdk.threads_leave()

    progress_total = 0
    while True:
        try:
            event = eventHandler.waitEvent(0.25)
            if gtkthread.quit.isSet():
                _, error = server.runCommand(["stateForceShutdown"])
                if error:
                    print('Unable to cleanly stop: %s' % error)
                break

            if event is None:
                continue

            if isinstance(event, bb.event.CacheLoadStarted):
                progress_total = event.total
                gtk.gdk.threads_enter()
                bardialog.set_title("Loading Cache")
                pbar.update(0)
                gtk.gdk.threads_leave()

            if isinstance(event, bb.event.CacheLoadProgress):
                x = event.current
                gtk.gdk.threads_enter()
                pbar.update(x * 1.0 / progress_total)
                pbar.set_title('')
                gtk.gdk.threads_leave()
                continue

            if isinstance(event, bb.event.CacheLoadCompleted):
                bardialog.hide()
                continue

            if isinstance(event, bb.event.ParseStarted):
                progress_total = event.total
                if progress_total == 0:
                    continue
                gtk.gdk.threads_enter()
                pbar.update(0)
                bardialog.set_title("Processing recipes")

                gtk.gdk.threads_leave()

            if isinstance(event, bb.event.ParseProgress):
                x = event.current
                gtk.gdk.threads_enter()
                pbar.update(x * 1.0 / progress_total)
                pbar.set_title('')
                gtk.gdk.threads_leave()
                continue

            if isinstance(event, bb.event.ParseCompleted):
                bardialog.hide()
                continue

            if isinstance(event, bb.event.DepTreeGenerated):
                gtk.gdk.threads_enter()
                dep.parse(event._depgraph)
                gtk.gdk.threads_leave()

            if isinstance(event, bb.command.CommandCompleted):
                continue

            if isinstance(event, bb.command.CommandFailed):
                print("Command execution failed: %s" % event.error)
                return event.exitcode

            if isinstance(event, bb.command.CommandExit):
                return event.exitcode

            if isinstance(event, bb.cooker.CookerExit):
                break

            continue
        except EnvironmentError as ioerror:
            # ignore interrupted io
            if ioerror.args[0] == 4:
                pass
        except KeyboardInterrupt:
            if shutdown == 2:
                print("\nThird Keyboard Interrupt, exit.\n")
                break
            if shutdown == 1:
                print("\nSecond Keyboard Interrupt, stopping...\n")
                _, error = server.runCommand(["stateForceShutdown"])
                if error:
                    print('Unable to cleanly stop: %s' % error)
            if shutdown == 0:
                print("\nKeyboard Interrupt, closing down...\n")
                _, error = server.runCommand(["stateShutdown"])
                if error:
                    print('Unable to cleanly shutdown: %s' % error)
            shutdown = shutdown + 1
            pass
コード例 #28
0
ファイル: deployimagedialog.py プロジェクト: 117111302/poky
    def create_visual_elements(self):
        self.set_size_request(600, 400)
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
        label.set_markup(markup)
        self.vbox.pack_start(label, expand=False, fill=False, padding=2)

        table = gtk.Table(2, 10, False)
        table.set_col_spacings(5)
        table.set_row_spacings(5)
        self.vbox.pack_start(table, expand=True, fill=True)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        tv = gtk.TextView()
        tv.set_editable(False)
        tv.set_wrap_mode(gtk.WRAP_WORD)
        tv.set_cursor_visible(False)
        self.buf = gtk.TextBuffer()
        self.buf.set_text(self.image_path)
        tv.set_buffer(self.buf)
        scroll.add(tv)
        table.attach(scroll, 0, 10, 0, 1)

        # There are 2 ways to use DeployImageDialog
        # One way is that called by HOB when the 'Deploy Image' button is clicked
        # The other way is that called by a standalone script.
        # Following block of codes handles the latter way. It adds a 'Select Image' button and
        # emit a signal when the button is clicked.
        if self.standalone:
                gobject.signal_new("select_image_clicked", self, gobject.SIGNAL_RUN_FIRST,
                                   gobject.TYPE_NONE, ())
                icon = gtk.Image()
                pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_IMAGES_DISPLAY_FILE)
                icon.set_from_pixbuf(pix_buffer)
                button = gtk.Button("Select Image")
                button.set_image(icon)
                #button.set_size_request(140, 50)
                table.attach(button, 9, 10, 1, 2, gtk.FILL, 0, 0, 0)
                button.connect("clicked", self.select_image_button_clicked_cb)

        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=False, padding=10)

        self.usb_desc = gtk.Label()
        self.usb_desc.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
        self.usb_desc.set_markup(markup)

        self.usb_combo = gtk.combo_box_new_text()
        self.usb_combo.connect("changed", self.usb_combo_changed_cb)
        model = self.usb_combo.get_model()
        model.clear()
        self.usb_combo.append_text(self.__dummy_usb__)
        for usb in self.find_all_usb_devices():
            self.usb_combo.append_text("/dev/" + usb)
        self.usb_combo.set_active(0)
        self.vbox.pack_start(self.usb_combo, expand=False, fill=False)
        self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=True, padding=10)

        self.vbox.show_all()
        self.progress_bar.hide()
コード例 #29
0
class ImageConfigurationPage(HobPage):

    __dummy_machine__ = "--select a machine--"
    __dummy_image__ = "--select a base image--"

    def __init__(self, builder):
        super(ImageConfigurationPage, self).__init__(builder,
                                                     "Image configuration")

        self.image_combo_id = None
        # we use machine_combo_changed_by_manual to identify the machine is changed by code
        # or by manual. If by manual, all user's recipe selection and package selection are
        # cleared.
        self.machine_combo_changed_by_manual = True
        self.stopping = False
        self.create_visual_elements()

    def create_visual_elements(self):
        # create visual elements
        self.toolbar = gtk.Toolbar()
        self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL)
        self.toolbar.set_style(gtk.TOOLBAR_BOTH)

        template_button = self.append_toolbar_button(
            self.toolbar, "Templates", hic.ICON_TEMPLATES_DISPLAY_FILE,
            hic.ICON_TEMPLATES_HOVER_FILE, "Load a previously saved template",
            self.template_button_clicked_cb)
        my_images_button = self.append_toolbar_button(
            self.toolbar, "Images", hic.ICON_IMAGES_DISPLAY_FILE,
            hic.ICON_IMAGES_HOVER_FILE, "Open previously built images",
            self.my_images_button_clicked_cb)
        settings_button = self.append_toolbar_button(
            self.toolbar, "Settings", hic.ICON_SETTINGS_DISPLAY_FILE,
            hic.ICON_SETTINGS_HOVER_FILE, "View additional build settings",
            self.settings_button_clicked_cb)

        self.config_top_button = self.add_onto_top_bar(self.toolbar)

        self.gtable = gtk.Table(40, 40, True)
        self.create_config_machine()
        self.create_config_baseimg()
        self.config_build_button = self.create_config_build_button()

    def _remove_all_widget(self):
        children = self.gtable.get_children() or []
        for child in children:
            self.gtable.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 _pack_components(self, pack_config_build_button=False):
        self._remove_all_widget()
        self.pack_start(self.config_top_button, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        self.box_group_area.pack_start(self.gtable, expand=True, fill=True)
        if pack_config_build_button:
            self.box_group_area.pack_end(self.config_build_button,
                                         expand=False,
                                         fill=False)
        else:
            box = gtk.HBox(False, 6)
            box.show()
            subbox = gtk.HBox(False, 0)
            subbox.set_size_request(205, 49)
            subbox.show()
            box.add(subbox)
            self.box_group_area.pack_end(box, False, False)

    def show_machine(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button=False)
        self.set_config_machine_layout(show_progress_bar=False)
        self.show_all()

    def update_progress_bar(self, title, fraction, status=None):
        if self.stopping == False:
            self.progress_bar.update(fraction)
            self.progress_bar.set_text(title)
            self.progress_bar.set_rcstyle(status)

    def show_info_populating(self):
        self._pack_components(pack_config_build_button=False)
        self.set_config_machine_layout(show_progress_bar=True)
        self.show_all()

    def show_info_populated(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button=False)
        self.set_config_machine_layout(show_progress_bar=False)
        self.set_config_baseimg_layout()
        self.show_all()

    def show_baseimg_selected(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button=True)
        self.set_config_machine_layout(show_progress_bar=False)
        self.set_config_baseimg_layout()
        self.show_all()
        if self.builder.recipe_model.get_selected_image(
        ) == self.builder.recipe_model.__custom_image__:
            self.just_bake_button.hide()

    def create_config_machine(self):
        self.machine_title = gtk.Label()
        self.machine_title.set_alignment(0.0, 0.5)
        mark = "<span %s>Select a machine</span>" % self.span_tag(
            'x-large', 'bold')
        self.machine_title.set_markup(mark)

        self.machine_title_desc = gtk.Label()
        self.machine_title_desc.set_alignment(0.0, 0.5)
        mark = (
            "<span %s>Your selection is the profile of the target machine for which you"
            " are building the image.\n</span>") % (self.span_tag('medium'))
        self.machine_title_desc.set_markup(mark)

        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.connect("changed", self.machine_combo_changed_cb)

        icon_file = hic.ICON_LAYERS_DISPLAY_FILE
        hover_file = hic.ICON_LAYERS_HOVER_FILE
        self.layer_button = HobImageButton(
            "Layers", "Add support for machines, software, etc.", icon_file,
            hover_file)
        self.layer_button.connect("clicked", self.layer_button_clicked_cb)

        markup = "Layers are a powerful mechanism to extend the Yocto Project "
        markup += "with your own functionality.\n"
        markup += "For more on layers, check the <a href=\""
        markup += "http://www.yoctoproject.org/docs/current/dev-manual/"
        markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>."
        self.layer_info_icon = HobInfoButton(markup, self.get_parent())

        #        self.progress_box = gtk.HBox(False, 6)
        self.progress_bar = HobProgressBar()
        #        self.progress_box.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.progress_box.pack_end(stop_button, expand=False, fill=False)
        self.machine_separator = gtk.HSeparator()

    def set_config_machine_layout(self, show_progress_bar=False):
        self.gtable.attach(self.machine_title, 0, 40, 0, 4)
        self.gtable.attach(self.machine_title_desc, 0, 40, 4, 6)
        self.gtable.attach(self.machine_combo, 0, 12, 7, 10)
        self.gtable.attach(self.layer_button, 14, 36, 7, 12)
        self.gtable.attach(self.layer_info_icon, 36, 40, 7, 11)
        if show_progress_bar:
            #self.gtable.attach(self.progress_box, 0, 40, 15, 18)
            self.gtable.attach(self.progress_bar, 0, 37, 15, 18)
            self.gtable.attach(self.stop_button, 37, 40, 15, 18, 0, 0)
        self.gtable.attach(self.machine_separator, 0, 40, 13, 14)

    def create_config_baseimg(self):
        self.image_title = gtk.Label()
        self.image_title.set_alignment(0, 1.0)
        mark = "<span %s>Select a base image</span>" % self.span_tag(
            'x-large', 'bold')
        self.image_title.set_markup(mark)

        self.image_title_desc = gtk.Label()
        self.image_title_desc.set_alignment(0, 0.5)
        mark = (
            "<span %s>Base images are a starting point for the type of image you want. "
            "You can build them as \n"
            "they are or customize them to your specific needs.\n</span>"
        ) % self.span_tag('medium')
        self.image_title_desc.set_markup(mark)

        self.image_combo = gtk.combo_box_new_text()
        self.image_combo_id = self.image_combo.connect(
            "changed", self.image_combo_changed_cb)

        self.image_desc = gtk.Label()
        self.image_desc.set_alignment(0.0, 0.5)
        self.image_desc.set_size_request(256, -1)
        self.image_desc.set_justify(gtk.JUSTIFY_LEFT)
        self.image_desc.set_line_wrap(True)

        # button to view recipes
        icon_file = hic.ICON_RCIPE_DISPLAY_FILE
        hover_file = hic.ICON_RCIPE_HOVER_FILE
        self.view_adv_configuration_button = HobImageButton(
            "Advanced configuration",
            "Select image types, package formats, etc", icon_file, hover_file)
        self.view_adv_configuration_button.connect(
            "clicked", self.view_adv_configuration_button_clicked_cb)

        self.image_separator = gtk.HSeparator()

    def set_config_baseimg_layout(self):
        self.gtable.attach(self.image_title, 0, 40, 15, 17)
        self.gtable.attach(self.image_title_desc, 0, 40, 18, 22)
        self.gtable.attach(self.image_combo, 0, 12, 23, 26)
        self.gtable.attach(self.image_desc, 0, 12, 27, 33)
        self.gtable.attach(self.view_adv_configuration_button, 14, 36, 23, 28)
        self.gtable.attach(self.image_separator, 0, 40, 35, 36)

    def create_config_build_button(self):
        # Create the "Build packages" and "Build image" buttons at the bottom
        button_box = gtk.HBox(False, 6)

        # create button "Build image"
        self.just_bake_button = HobButton("Build image")
        #self.just_bake_button.set_size_request(205, 49)
        self.just_bake_button.set_tooltip_text("Build target image")
        self.just_bake_button.connect("clicked",
                                      self.just_bake_button_clicked_cb)
        button_box.pack_end(self.just_bake_button, expand=False, fill=False)

        # create button "Edit Image"
        self.edit_image_button = HobAltButton("Edit image")
        #self.edit_image_button.set_size_request(205, 49)
        self.edit_image_button.set_tooltip_text("Edit target image")
        self.edit_image_button.connect("clicked",
                                       self.edit_image_button_clicked_cb)
        button_box.pack_end(self.edit_image_button, expand=False, fill=False)

        return button_box

    def stop_button_clicked_cb(self, button):
        self.stopping = True
        self.progress_bar.set_text("Stopping recipe parsing")
        self.progress_bar.set_rcstyle("stop")
        self.builder.cancel_parse_sync()

    def machine_combo_changed_cb(self, machine_combo):
        self.stopping = False
        combo_item = machine_combo.get_active_text()
        if not combo_item or combo_item == self.__dummy_machine__:
            return

        # remove __dummy_machine__ item from the store list after first user selection
        # because it is no longer valid
        combo_store = machine_combo.get_model()
        if len(combo_store) and (combo_store[0][0] == self.__dummy_machine__):
            machine_combo.remove_text(0)

        self.builder.configuration.curr_mach = combo_item
        if self.machine_combo_changed_by_manual:
            self.builder.configuration.clear_selection()
        # reset machine_combo_changed_by_manual
        self.machine_combo_changed_by_manual = True

        # Do reparse recipes
        self.builder.populate_recipe_package_info_async()

    def update_machine_combo(self):
        all_machines = [self.__dummy_machine__
                        ] + self.builder.parameters.all_machines

        model = self.machine_combo.get_model()
        model.clear()
        for machine in all_machines:
            self.machine_combo.append_text(machine)
        self.machine_combo.set_active(0)

    def switch_machine_combo(self):
        self.machine_combo_changed_by_manual = False
        model = self.machine_combo.get_model()
        active = 0
        while active < len(model):
            if model[active][0] == self.builder.configuration.curr_mach:
                self.machine_combo.set_active(active)
                return
            active += 1

        if model[0][0] != self.__dummy_machine__:
            self.machine_combo.insert_text(0, self.__dummy_machine__)

        self.machine_combo.set_active(0)

    def update_image_desc(self):
        desc = ""
        selected_image = self.image_combo.get_active_text()
        if selected_image and selected_image in self.builder.recipe_model.pn_path.keys(
        ):
            image_path = self.builder.recipe_model.pn_path[selected_image]
            image_iter = self.builder.recipe_model.get_iter(image_path)
            desc = self.builder.recipe_model.get_value(
                image_iter, self.builder.recipe_model.COL_DESC)

        mark = ("<span %s>%s</span>\n") % (self.span_tag('small'), desc)
        self.image_desc.set_markup(mark)

    def image_combo_changed_idle_cb(self, selected_image, selected_recipes,
                                    selected_packages):
        self.builder.update_recipe_model(selected_image, selected_recipes)
        self.builder.update_package_model(selected_packages)
        self.builder.window_sensitive(True)

    def image_combo_changed_cb(self, combo):
        self.builder.window_sensitive(False)
        selected_image = self.image_combo.get_active_text()
        if not selected_image or (selected_image == self.__dummy_image__):
            return

        # remove __dummy_image__ item from the store list after first user selection
        # because it is no longer valid
        combo_store = combo.get_model()
        if len(combo_store) and (combo_store[0][0] == self.__dummy_image__):
            combo.remove_text(0)

        self.builder.customized = False

        selected_recipes = []

        image_path = self.builder.recipe_model.pn_path[selected_image]
        image_iter = self.builder.recipe_model.get_iter(image_path)
        selected_packages = self.builder.recipe_model.get_value(
            image_iter, self.builder.recipe_model.COL_INSTALL).split()
        self.update_image_desc()

        self.builder.recipe_model.reset()
        self.builder.package_model.reset()

        self.show_baseimg_selected()

        if selected_image == self.builder.recipe_model.__custom_image__:
            self.just_bake_button.hide()

        glib.idle_add(self.image_combo_changed_idle_cb, selected_image,
                      selected_recipes, selected_packages)

    def _image_combo_connect_signal(self):
        if not self.image_combo_id:
            self.image_combo_id = self.image_combo.connect(
                "changed", self.image_combo_changed_cb)

    def _image_combo_disconnect_signal(self):
        if self.image_combo_id:
            self.image_combo.disconnect(self.image_combo_id)
            self.image_combo_id = None

    def update_image_combo(self, recipe_model, selected_image):
        # Update the image combo according to the images in the recipe_model
        # populate image combo
        filter = {RecipeListModel.COL_TYPE: ['image']}
        image_model = recipe_model.tree_model(filter)
        image_model.set_sort_column_id(recipe_model.COL_NAME,
                                       gtk.SORT_ASCENDING)
        active = 0
        cnt = 1

        white_pattern = []
        if self.builder.parameters.image_white_pattern:
            for i in self.builder.parameters.image_white_pattern.split():
                white_pattern.append(re.compile(i))

        black_pattern = []
        if self.builder.parameters.image_black_pattern:
            for i in self.builder.parameters.image_black_pattern.split():
                black_pattern.append(re.compile(i))
        black_pattern.append(re.compile("hob-image"))

        it = image_model.get_iter_first()
        self._image_combo_disconnect_signal()
        model = self.image_combo.get_model()
        model.clear()
        # Set a indicator text to combo store when first open
        self.image_combo.append_text(self.__dummy_image__)
        # append and set active
        while it:
            path = image_model.get_path(it)
            it = image_model.iter_next(it)
            image_name = image_model[path][recipe_model.COL_NAME]
            if image_name == self.builder.recipe_model.__custom_image__:
                continue

            if black_pattern:
                allow = True
                for pattern in black_pattern:
                    if pattern.search(image_name):
                        allow = False
                        break
            elif white_pattern:
                allow = False
                for pattern in white_pattern:
                    if pattern.search(image_name):
                        allow = True
                        break
            else:
                allow = True

            if allow:
                self.image_combo.append_text(image_name)
                if image_name == selected_image:
                    active = cnt
                cnt = cnt + 1

        self.image_combo.append_text(
            self.builder.recipe_model.__custom_image__)
        if selected_image == self.builder.recipe_model.__custom_image__:
            active = cnt

        self.image_combo.set_active(active)

        if active != 0:
            self.show_baseimg_selected()

        self._image_combo_connect_signal()

    def layer_button_clicked_cb(self, button):
        # Create a layer selection dialog
        self.builder.show_layer_selection_dialog()

    def view_adv_configuration_button_clicked_cb(self, button):
        # Create an advanced settings dialog
        response, settings_changed = self.builder.show_adv_settings_dialog()
        if not response:
            return
        if settings_changed:
            self.builder.reparse_post_adv_settings()

    def just_bake_button_clicked_cb(self, button):
        self.builder.just_bake()

    def edit_image_button_clicked_cb(self, button):
        self.builder.configuration.initial_selected_image = self.builder.configuration.selected_image
        self.builder.show_recipes()

    def template_button_clicked_cb(self, button):
        response, path = self.builder.show_load_template_dialog()
        if not response:
            return
        if path:
            self.builder.load_template(path)

    def my_images_button_clicked_cb(self, button):
        self.builder.show_load_my_images_dialog()

    def settings_button_clicked_cb(self, button):
        # Create an advanced settings dialog
        response, settings_changed = self.builder.show_simple_settings_dialog()
        if not response:
            return
        if settings_changed:
            self.builder.reparse_post_adv_settings()
コード例 #30
0
ファイル: hig.py プロジェクト: ReaLCodeBreaker/OE-gum
class DeployImageDialog (CrumbsDialog):

    __dummy_usb__ = "--select a usb drive--"

    def __init__(self, title, image_path, parent, flags, buttons=None):
        super(DeployImageDialog, self).__init__(title, parent, flags, buttons)

        self.image_path = image_path

        self.create_visual_elements()
        self.connect("response", self.response_cb)

    def create_visual_elements(self):
        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>The image to be written into usb drive:</span>"
        label.set_markup(markup)
        self.vbox.pack_start(label, expand=False, fill=False, padding=2)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        tv = gtk.TextView()
        tv.set_editable(False)
        tv.set_wrap_mode(gtk.WRAP_WORD)
        tv.set_cursor_visible(False)
        buf = gtk.TextBuffer()
        buf.set_text(self.image_path)
        tv.set_buffer(buf)
        scroll.add(tv)
        self.vbox.pack_start(scroll, expand=True, fill=True)

        self.usb_desc = gtk.Label()
        self.usb_desc.set_alignment(0.0, 0.5)
        markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
        self.usb_desc.set_markup(markup)

        self.usb_combo = gtk.combo_box_new_text()
        self.usb_combo.connect("changed", self.usb_combo_changed_cb)
        model = self.usb_combo.get_model()
        model.clear()
        self.usb_combo.append_text(self.__dummy_usb__)
        for usb in self.find_all_usb_devices():
            self.usb_combo.append_text("/dev/" + usb)
        self.usb_combo.set_active(0)
        self.vbox.pack_start(self.usb_combo, expand=True, fill=True)
        self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2)

        self.progress_bar = HobProgressBar()
        self.vbox.pack_start(self.progress_bar, expand=False, fill=False)
        separator = gtk.HSeparator()
        self.vbox.pack_start(separator, expand=False, fill=True, padding=10)

        self.vbox.show_all()
        self.progress_bar.hide()

    def popen_read(self, cmd):
        return os.popen("%s 2>/dev/null" % cmd).read().strip()

    def find_all_usb_devices(self):
        usb_devs = [ os.readlink(u)
            for u in self.popen_read('ls /dev/disk/by-id/usb*').split()
            if not re.search(r'part\d+', u) ]
        return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ]

    def get_usb_info(self, dev):
        return "%s %s" % \
            (self.popen_read('cat /sys/class/block/%s/device/vendor' % dev),
            self.popen_read('cat /sys/class/block/%s/device/model' % dev))

    def usb_combo_changed_cb(self, usb_combo):
        combo_item = self.usb_combo.get_active_text()
        if not combo_item or combo_item == self.__dummy_usb__:
            markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>"
            self.usb_desc.set_markup(markup)
        else:
            markup = "<span font_desc='12'>" + self.get_usb_info(combo_item.lstrip("/dev/")) + "</span>"
            self.usb_desc.set_markup(markup)

    def response_cb(self, dialog, response_id):
        if response_id == gtk.RESPONSE_YES:
            combo_item = self.usb_combo.get_active_text()
            if combo_item and combo_item != self.__dummy_usb__:
                cmdline = bb.ui.crumbs.utils.which_terminal()
                if cmdline:
                    cmdline += "\"sudo dd if=" + self.image_path + " of=" + combo_item + "\""
                    subprocess.Popen(args=shlex.split(cmdline))

    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 write_file(self, ifile, ofile):
        self.progress_bar.reset()
        self.progress_bar.show()

        f_from = os.open(ifile, os.O_RDONLY)
        f_to = os.open(ofile, os.O_WRONLY)

        total_size = os.stat(ifile).st_size
        written_size = 0

        while True:
            buf = os.read(f_from, 1024*1024)
            if not buf:
                break
            os.write(f_to, buf)
            written_size += 1024*1024
            self.update_progress_bar("Writing to usb:", written_size * 1.0/total_size)

        self.update_progress_bar("Writing completed:", 1.0)
        os.close(f_from)
        os.close(f_to)
        self.progress_bar.hide()
コード例 #31
0
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('&lt;&lt; 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")
コード例 #32
0
    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
コード例 #33
0
 def create_config_machine(self):
     self.progress_bar = HobProgressBar()
コード例 #34
0
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('&lt;&lt; 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")
コード例 #35
0
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)
コード例 #36
0
class ImageConfigurationPage(HobPage):

    __dummy_machine__ = "--select a machine--"
    __dummy_image__ = "--select an image recipe--"
    __custom_image__ = "Select from my image recipes"

    def __init__(self, builder):
        super(ImageConfigurationPage, self).__init__(builder,
                                                     "Image configuration")

        self.image_combo_id = None
        # we use machine_combo_changed_by_manual to identify the machine is changed by code
        # or by manual. If by manual, all user's recipe selection and package selection are
        # cleared.
        self.machine_combo_changed_by_manual = True
        self.stopping = False
        self.warning_shift = 0
        self.custom_image_selected = None
        self.create_visual_elements()

    def create_visual_elements(self):
        # create visual elements
        self.toolbar = gtk.Toolbar()
        self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL)
        self.toolbar.set_style(gtk.TOOLBAR_BOTH)

        my_images_button = self.append_toolbar_button(
            self.toolbar, "Images", hic.ICON_IMAGES_DISPLAY_FILE,
            hic.ICON_IMAGES_HOVER_FILE, "Open previously built images",
            self.my_images_button_clicked_cb)
        settings_button = self.append_toolbar_button(
            self.toolbar, "Settings", hic.ICON_SETTINGS_DISPLAY_FILE,
            hic.ICON_SETTINGS_HOVER_FILE, "View additional build settings",
            self.settings_button_clicked_cb)

        self.config_top_button = self.add_onto_top_bar(self.toolbar)

        self.gtable = gtk.Table(40, 40, True)
        self.create_config_machine()
        self.create_config_baseimg()
        self.config_build_button = self.create_config_build_button()

    def _remove_all_widget(self):
        children = self.gtable.get_children() or []
        for child in children:
            self.gtable.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 _pack_components(self, pack_config_build_button=False):
        self._remove_all_widget()
        self.pack_start(self.config_top_button, expand=False, fill=False)
        self.pack_start(self.group_align, expand=True, fill=True)

        self.box_group_area.pack_start(self.gtable, expand=True, fill=True)
        if pack_config_build_button:
            self.box_group_area.pack_end(self.config_build_button,
                                         expand=False,
                                         fill=False)
        else:
            box = gtk.HBox(False, 6)
            box.show()
            subbox = gtk.HBox(False, 0)
            subbox.set_size_request(205, 49)
            subbox.show()
            box.add(subbox)
            self.box_group_area.pack_end(box, False, False)

    def show_machine(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button=False)
        self.set_config_machine_layout(show_progress_bar=False)
        self.show_all()

    def update_progress_bar(self, title, fraction, status=None):
        if self.stopping == False:
            self.progress_bar.update(fraction)
            self.progress_bar.set_text(title)
            self.progress_bar.set_rcstyle(status)

    def show_info_populating(self):
        self._pack_components(pack_config_build_button=False)
        self.set_config_machine_layout(show_progress_bar=True)
        self.show_all()

    def show_info_populated(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button=False)
        self.set_config_machine_layout(show_progress_bar=False)
        self.set_config_baseimg_layout()
        self.show_all()

    def show_baseimg_selected(self):
        self.progress_bar.reset()
        self._pack_components(pack_config_build_button=True)
        self.set_config_machine_layout(show_progress_bar=False)
        self.set_config_baseimg_layout()
        self.show_all()
        if self.builder.recipe_model.get_selected_image(
        ) == self.builder.recipe_model.__custom_image__:
            self.just_bake_button.hide()

    def add_warnings_bar(self):
        #create the warnings bar shown when recipes parsing generates warnings
        color = HobColors.KHAKI
        warnings_bar = gtk.EventBox()
        warnings_bar.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
        warnings_bar.set_flags(gtk.CAN_DEFAULT)
        warnings_bar.grab_default()

        build_stop_tab = gtk.Table(10, 20, True)
        warnings_bar.add(build_stop_tab)

        icon = gtk.Image()
        icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(
            hic.ICON_INDI_ALERT_FILE)
        icon.set_from_pixbuf(icon_pix_buffer)
        build_stop_tab.attach(icon, 0, 2, 0, 10)

        label = gtk.Label()
        label.set_alignment(0.0, 0.5)
        warnings_nb = len(self.builder.parsing_warnings)
        if warnings_nb == 1:
            label.set_markup(
                "<span size='x-large'><b>1 recipe parsing warning</b></span>")
        else:
            label.set_markup(
                "<span size='x-large'><b>%s recipe parsing warnings</b></span>"
                % warnings_nb)
        build_stop_tab.attach(label, 2, 12, 0, 10)

        view_warnings_button = HobButton("View warnings")
        view_warnings_button.connect('clicked',
                                     self.view_warnings_button_clicked_cb)
        build_stop_tab.attach(view_warnings_button, 15, 19, 1, 9)

        return warnings_bar

    def disable_warnings_bar(self):
        if self.builder.parsing_warnings:
            if hasattr(self, 'warnings_bar'):
                self.warnings_bar.hide_all()
            self.builder.parsing_warnings = []

    def create_config_machine(self):
        self.machine_title = gtk.Label()
        self.machine_title.set_alignment(0.0, 0.5)
        mark = "<span %s>Select a machine</span>" % self.span_tag(
            'x-large', 'bold')
        self.machine_title.set_markup(mark)

        self.machine_title_desc = gtk.Label()
        self.machine_title_desc.set_alignment(0.0, 0.5)
        mark = (
            "<span %s>Your selection is the profile of the target machine for which you"
            " are building the image.\n</span>") % (self.span_tag('medium'))
        self.machine_title_desc.set_markup(mark)

        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.connect("changed", self.machine_combo_changed_cb)

        icon_file = hic.ICON_LAYERS_DISPLAY_FILE
        hover_file = hic.ICON_LAYERS_HOVER_FILE
        self.layer_button = HobImageButton(
            "Layers", "Add support for machines, software, etc.", icon_file,
            hover_file)
        self.layer_button.connect("clicked", self.layer_button_clicked_cb)

        markup = "Layers are a powerful mechanism to extend the Yocto Project "
        markup += "with your own functionality.\n"
        markup += "For more on layers, check the <a href=\""
        markup += "http://www.yoctoproject.org/docs/current/dev-manual/"
        markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>."
        self.layer_info_icon = HobInfoButton("<b>Layers</b>" + "*" + markup,
                                             self.get_parent())
        self.progress_bar = HobProgressBar()
        self.stop_button = HobAltButton("Stop")
        self.stop_button.connect("clicked", self.stop_button_clicked_cb)
        self.machine_separator = gtk.HSeparator()

    def set_config_machine_layout(self, show_progress_bar=False):
        self.gtable.attach(self.machine_title, 0, 40, 0, 4)
        self.gtable.attach(self.machine_title_desc, 0, 40, 4, 6)
        self.gtable.attach(self.machine_combo, 0, 12, 7, 10)
        self.gtable.attach(self.layer_button, 14, 36, 7, 12)
        self.gtable.attach(self.layer_info_icon, 36, 40, 7, 11)
        if show_progress_bar:
            #self.gtable.attach(self.progress_box, 0, 40, 15, 18)
            self.gtable.attach(self.progress_bar, 0, 37, 15, 18)
            self.gtable.attach(self.stop_button, 37, 40, 15, 18, 0, 0)
        if self.builder.parsing_warnings:
            self.warnings_bar = self.add_warnings_bar()
            self.gtable.attach(self.warnings_bar, 0, 40, 14, 18)
            self.warning_shift = 4
        else:
            self.warning_shift = 0
        self.gtable.attach(self.machine_separator, 0, 40, 13, 14)

    def create_config_baseimg(self):
        self.image_title = gtk.Label()
        self.image_title.set_alignment(0, 1.0)
        mark = "<span %s>Select an image recipe</span>" % self.span_tag(
            'x-large', 'bold')
        self.image_title.set_markup(mark)

        self.image_title_desc = gtk.Label()
        self.image_title_desc.set_alignment(0, 0.5)

        mark = (
            "<span %s>Image recipes are a starting point for the type of image you want. "
            "You can build them as \n"
            "they are or edit them to suit your needs.\n</span>"
        ) % self.span_tag('medium')
        self.image_title_desc.set_markup(mark)

        self.image_combo = gtk.combo_box_new_text()
        self.image_combo.set_row_separator_func(self.combo_separator_func,
                                                None)
        self.image_combo_id = self.image_combo.connect(
            "changed", self.image_combo_changed_cb)

        self.image_desc = gtk.Label()
        self.image_desc.set_alignment(0.0, 0.5)
        self.image_desc.set_size_request(256, -1)
        self.image_desc.set_justify(gtk.JUSTIFY_LEFT)
        self.image_desc.set_line_wrap(True)

        # button to view recipes
        icon_file = hic.ICON_RCIPE_DISPLAY_FILE
        hover_file = hic.ICON_RCIPE_HOVER_FILE
        self.view_adv_configuration_button = HobImageButton(
            "Advanced configuration",
            "Select image types, package formats, etc", icon_file, hover_file)
        self.view_adv_configuration_button.connect(
            "clicked", self.view_adv_configuration_button_clicked_cb)

        self.image_separator = gtk.HSeparator()

    def combo_separator_func(self, model, iter, user_data):
        name = model.get_value(iter, 0)
        if name == "--Separator--":
            return True

    def set_config_baseimg_layout(self):
        self.gtable.attach(self.image_title, 0, 40, 15 + self.warning_shift,
                           17 + self.warning_shift)
        self.gtable.attach(self.image_title_desc, 0, 40,
                           18 + self.warning_shift, 22 + self.warning_shift)
        self.gtable.attach(self.image_combo, 0, 12, 23 + self.warning_shift,
                           26 + self.warning_shift)
        self.gtable.attach(self.image_desc, 0, 12, 27 + self.warning_shift,
                           33 + self.warning_shift)
        self.gtable.attach(self.view_adv_configuration_button, 14, 36,
                           23 + self.warning_shift, 28 + self.warning_shift)
        self.gtable.attach(self.image_separator, 0, 40,
                           35 + self.warning_shift, 36 + self.warning_shift)

    def create_config_build_button(self):
        # Create the "Build packages" and "Build image" buttons at the bottom
        button_box = gtk.HBox(False, 6)

        # create button "Build image"
        self.just_bake_button = HobButton("Build image")
        self.just_bake_button.set_tooltip_text(
            "Build the image recipe as it is")
        self.just_bake_button.connect("clicked",
                                      self.just_bake_button_clicked_cb)
        button_box.pack_end(self.just_bake_button, expand=False, fill=False)

        # create button "Edit image recipe"
        self.edit_image_button = HobAltButton("Edit image recipe")
        self.edit_image_button.set_tooltip_text(
            "Customize the recipes and packages to be included in your image")
        self.edit_image_button.connect("clicked",
                                       self.edit_image_button_clicked_cb)
        button_box.pack_end(self.edit_image_button, expand=False, fill=False)

        return button_box

    def stop_button_clicked_cb(self, button):
        self.stopping = True
        self.progress_bar.set_text("Stopping recipe parsing")
        self.progress_bar.set_rcstyle("stop")
        self.builder.cancel_parse_sync()

    def view_warnings_button_clicked_cb(self, button):
        self.builder.show_warning_dialog()

    def machine_combo_changed_idle_cb(self):
        self.builder.window.set_cursor(None)

    def machine_combo_changed_cb(self, machine_combo):
        self.stopping = False
        self.builder.parsing_warnings = []
        combo_item = machine_combo.get_active_text()
        if not combo_item or combo_item == self.__dummy_machine__:
            return

        self.builder.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
        self.builder.wait(0.1)  #wait for combo and cursor to update

        # remove __dummy_machine__ item from the store list after first user selection
        # because it is no longer valid
        combo_store = machine_combo.get_model()
        if len(combo_store) and (combo_store[0][0] == self.__dummy_machine__):
            machine_combo.remove_text(0)

        self.builder.configuration.curr_mach = combo_item
        if self.machine_combo_changed_by_manual:
            self.builder.configuration.clear_selection()
        # reset machine_combo_changed_by_manual
        self.machine_combo_changed_by_manual = True

        self.builder.configuration.selected_image = None

        # Do reparse recipes
        self.builder.populate_recipe_package_info_async()

        glib.idle_add(self.machine_combo_changed_idle_cb)

    def update_machine_combo(self):
        self.disable_warnings_bar()
        all_machines = [self.__dummy_machine__
                        ] + self.builder.parameters.all_machines

        model = self.machine_combo.get_model()
        model.clear()
        for machine in all_machines:
            self.machine_combo.append_text(machine)
        self.machine_combo.set_active(0)

    def switch_machine_combo(self):
        self.disable_warnings_bar()
        self.machine_combo_changed_by_manual = False
        model = self.machine_combo.get_model()
        active = 0
        while active < len(model):
            if model[active][0] == self.builder.configuration.curr_mach:
                self.machine_combo.set_active(active)
                return
            active += 1

        if model[0][0] != self.__dummy_machine__:
            self.machine_combo.insert_text(0, self.__dummy_machine__)

        self.machine_combo.set_active(0)

    def update_image_desc(self):
        desc = ""
        selected_image = self.image_combo.get_active_text()
        if selected_image and selected_image in self.builder.recipe_model.pn_path.keys(
        ):
            image_path = self.builder.recipe_model.pn_path[selected_image]
            image_iter = self.builder.recipe_model.get_iter(image_path)
            desc = self.builder.recipe_model.get_value(
                image_iter, self.builder.recipe_model.COL_DESC)

        mark = ("<span %s>%s</span>\n") % (self.span_tag('small'), desc)
        self.image_desc.set_markup(mark)

    def image_combo_changed_idle_cb(self, selected_image, selected_recipes,
                                    selected_packages):
        self.builder.update_recipe_model(selected_image, selected_recipes)
        self.builder.update_package_model(selected_packages)
        self.builder.window_sensitive(True)

    def image_combo_changed_cb(self, combo):
        self.builder.window_sensitive(False)
        selected_image = self.image_combo.get_active_text()
        if selected_image == self.__custom_image__:
            topdir = self.builder.get_topdir()
            images_dir = topdir + "/recipes/images/"
            self.builder.ensure_dir(images_dir)

            dialog = RetrieveImageDialog(
                images_dir, "Select from my image recipes", self.builder,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
            response = dialog.run()
            if response == gtk.RESPONSE_OK:
                image_name = dialog.get_filename()
                head, tail = os.path.split(image_name)
                selected_image = os.path.splitext(tail)[0]
                self.custom_image_selected = selected_image
                self.update_image_combo(self.builder.recipe_model,
                                        selected_image)
            else:
                selected_image = self.__dummy_image__
                self.update_image_combo(self.builder.recipe_model, None)
            dialog.destroy()
        else:
            if self.custom_image_selected:
                self.custom_image_selected = None
                self.update_image_combo(self.builder.recipe_model,
                                        selected_image)

        if not selected_image or (selected_image == self.__dummy_image__):
            self.builder.window_sensitive(True)
            self.just_bake_button.hide()
            self.edit_image_button.hide()
            return

        # remove __dummy_image__ item from the store list after first user selection
        # because it is no longer valid
        combo_store = combo.get_model()
        if len(combo_store) and (combo_store[0][0] == self.__dummy_image__):
            combo.remove_text(0)

        self.builder.customized = False

        selected_recipes = []

        image_path = self.builder.recipe_model.pn_path[selected_image]
        image_iter = self.builder.recipe_model.get_iter(image_path)
        selected_packages = self.builder.recipe_model.get_value(
            image_iter, self.builder.recipe_model.COL_INSTALL).split()
        self.update_image_desc()

        self.builder.recipe_model.reset()
        self.builder.package_model.reset()

        self.show_baseimg_selected()

        if selected_image == self.builder.recipe_model.__custom_image__:
            self.just_bake_button.hide()

        glib.idle_add(self.image_combo_changed_idle_cb, selected_image,
                      selected_recipes, selected_packages)

    def _image_combo_connect_signal(self):
        if not self.image_combo_id:
            self.image_combo_id = self.image_combo.connect(
                "changed", self.image_combo_changed_cb)

    def _image_combo_disconnect_signal(self):
        if self.image_combo_id:
            self.image_combo.disconnect(self.image_combo_id)
            self.image_combo_id = None

    def update_image_combo(self, recipe_model, selected_image):
        # Update the image combo according to the images in the recipe_model
        # populate image combo
        filter = {RecipeListModel.COL_TYPE: ['image']}
        image_model = recipe_model.tree_model(filter)
        image_model.set_sort_column_id(recipe_model.COL_NAME,
                                       gtk.SORT_ASCENDING)
        active = 0
        cnt = 0

        white_pattern = []
        if self.builder.parameters.image_white_pattern:
            for i in self.builder.parameters.image_white_pattern.split():
                white_pattern.append(re.compile(i))

        black_pattern = []
        if self.builder.parameters.image_black_pattern:
            for i in self.builder.parameters.image_black_pattern.split():
                black_pattern.append(re.compile(i))
        black_pattern.append(re.compile("hob-image"))

        it = image_model.get_iter_first()
        self._image_combo_disconnect_signal()
        model = self.image_combo.get_model()
        model.clear()
        # Set a indicator text to combo store when first open
        if not selected_image:
            self.image_combo.append_text(self.__dummy_image__)
            cnt = cnt + 1

        self.image_combo.append_text(self.__custom_image__)
        self.image_combo.append_text("--Separator--")
        cnt = cnt + 2

        topdir = self.builder.get_topdir()
        # append and set active
        while it:
            path = image_model.get_path(it)
            it = image_model.iter_next(it)
            image_name = image_model[path][recipe_model.COL_NAME]
            if image_name == self.builder.recipe_model.__custom_image__:
                continue

            if black_pattern:
                allow = True
                for pattern in black_pattern:
                    if pattern.search(image_name):
                        allow = False
                        break
            elif white_pattern:
                allow = False
                for pattern in white_pattern:
                    if pattern.search(image_name):
                        allow = True
                        break
            else:
                allow = True

            file_name = image_model[path][recipe_model.COL_FILE]
            if file_name and topdir in file_name:
                allow = False

            if allow:
                self.image_combo.append_text(image_name)
                if image_name == selected_image:
                    active = cnt
                cnt = cnt + 1
        self.image_combo.append_text(
            self.builder.recipe_model.__custom_image__)

        if selected_image == self.builder.recipe_model.__custom_image__:
            active = cnt

        if self.custom_image_selected:
            self.image_combo.append_text("--Separator--")
            self.image_combo.append_text(self.custom_image_selected)
            cnt = cnt + 2
            if self.custom_image_selected == selected_image:
                active = cnt

        self.image_combo.set_active(active)

        if active != 0:
            self.show_baseimg_selected()

        self._image_combo_connect_signal()

    def layer_button_clicked_cb(self, button):
        # Create a layer selection dialog
        self.builder.show_layer_selection_dialog()

    def view_adv_configuration_button_clicked_cb(self, button):
        # Create an advanced settings dialog
        response, settings_changed = self.builder.show_adv_settings_dialog()
        if not response:
            return
        if settings_changed:
            self.builder.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
            self.builder.wait(0.1)  #wait for adv_settings_dialog to terminate
            self.builder.reparse_post_adv_settings()
            self.builder.window.set_cursor(None)

    def just_bake_button_clicked_cb(self, button):
        self.builder.parsing_warnings = []
        self.builder.just_bake()

    def edit_image_button_clicked_cb(self, button):
        self.builder.configuration.initial_selected_image = self.builder.configuration.selected_image
        self.builder.show_recipes()

    def my_images_button_clicked_cb(self, button):
        self.builder.show_load_my_images_dialog()

    def settings_button_clicked_cb(self, button):
        # Create an advanced settings dialog
        response, settings_changed = self.builder.show_simple_settings_dialog()
        if not response:
            return
        if settings_changed:
            self.builder.reparse_post_adv_settings()
コード例 #37
0
def main(server, eventHandler, params):
    try:
        params.updateFromServer(server)
        cmdline = params.parseActions()
        if not cmdline:
            print(
                "Nothing to do.  Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information."
            )
            return 1
        if 'msg' in cmdline and cmdline['msg']:
            print(cmdline['msg'])
            return 1
        cmdline = cmdline['action']
        if not cmdline or cmdline[0] != "generateDotGraph":
            print("This UI requires the -g option")
            return 1
        ret, error = server.runCommand(
            ["generateDepTreeEvent", cmdline[1], cmdline[2]])
        if error:
            print("Error running command '%s': %s" % (cmdline, error))
            return 1
        elif ret != True:
            print("Error running command '%s': returned %s" % (cmdline, ret))
            return 1
    except xmlrpclib.Fault as x:
        print("XMLRPC Fault getting commandline:\n %s" % x)
        return

    try:
        gtk.init_check()
    except RuntimeError:
        sys.stderr.write(
            "Please set DISPLAY variable before running this command \n")
        return

    shutdown = 0

    gtkgui = gtkthread(shutdown)
    gtkgui.start()

    gtk.gdk.threads_enter()
    dep = DepExplorer()
    bardialog = gtk.Dialog(parent=dep,
                           flags=gtk.DIALOG_MODAL
                           | gtk.DIALOG_DESTROY_WITH_PARENT)
    bardialog.set_default_size(400, 50)
    pbar = HobProgressBar()
    bardialog.vbox.pack_start(pbar)
    bardialog.show_all()
    bardialog.connect("delete-event", gtk.main_quit)
    gtk.gdk.threads_leave()

    progress_total = 0
    while True:
        try:
            event = eventHandler.waitEvent(0.25)
            if gtkthread.quit.isSet():
                _, error = server.runCommand(["stateForceShutdown"])
                if error:
                    print('Unable to cleanly stop: %s' % error)
                break

            if event is None:
                continue

            if isinstance(event, bb.event.CacheLoadStarted):
                progress_total = event.total
                gtk.gdk.threads_enter()
                bardialog.set_title("Loading Cache")
                pbar.update(0)
                gtk.gdk.threads_leave()

            if isinstance(event, bb.event.CacheLoadProgress):
                x = event.current
                gtk.gdk.threads_enter()
                pbar.update(x * 1.0 / progress_total)
                pbar.set_title('')
                gtk.gdk.threads_leave()
                continue

            if isinstance(event, bb.event.CacheLoadCompleted):
                bardialog.hide()
                continue

            if isinstance(event, bb.event.ParseStarted):
                progress_total = event.total
                if progress_total == 0:
                    continue
                gtk.gdk.threads_enter()
                pbar.update(0)
                bardialog.set_title("Processing recipes")

                gtk.gdk.threads_leave()

            if isinstance(event, bb.event.ParseProgress):
                x = event.current
                gtk.gdk.threads_enter()
                pbar.update(x * 1.0 / progress_total)
                pbar.set_title('')
                gtk.gdk.threads_leave()
                continue

            if isinstance(event, bb.event.ParseCompleted):
                bardialog.hide()
                continue

            if isinstance(event, bb.event.DepTreeGenerated):
                gtk.gdk.threads_enter()
                dep.parse(event._depgraph)
                gtk.gdk.threads_leave()

            if isinstance(event, bb.command.CommandCompleted):
                continue

            if isinstance(event, bb.command.CommandFailed):
                print("Command execution failed: %s" % event.error)
                return event.exitcode

            if isinstance(event, bb.command.CommandExit):
                return event.exitcode

            if isinstance(event, bb.cooker.CookerExit):
                break

            continue
        except EnvironmentError as ioerror:
            # ignore interrupted io
            if ioerror.args[0] == 4:
                pass
        except KeyboardInterrupt:
            if shutdown == 2:
                print("\nThird Keyboard Interrupt, exit.\n")
                break
            if shutdown == 1:
                print("\nSecond Keyboard Interrupt, stopping...\n")
                _, error = server.runCommand(["stateForceShutdown"])
                if error:
                    print('Unable to cleanly stop: %s' % error)
            if shutdown == 0:
                print("\nKeyboard Interrupt, closing down...\n")
                _, error = server.runCommand(["stateShutdown"])
                if error:
                    print('Unable to cleanly shutdown: %s' % error)
            shutdown = shutdown + 1
            pass
コード例 #38
0
ファイル: depexp.py プロジェクト: gosborne/yp
def main(server, eventHandler):
    try:
        cmdline = server.runCommand(["getCmdLineAction"])
        if cmdline and not cmdline['action']:
            print(cmdline['msg'])
            return
        elif not cmdline or (cmdline['action'] and cmdline['action'][0] != "generateDotGraph"):
            print("This UI is only compatible with the -g option")
            return
        ret = server.runCommand(["generateDepTreeEvent", cmdline['action'][1], cmdline['action'][2]])
        if ret != True:
            print("Couldn't run command! %s" % ret)
            return
    except xmlrpclib.Fault as x:
        print("XMLRPC Fault getting commandline:\n %s" % x)
        return

    shutdown = 0

    gtkgui = gtkthread(shutdown)
    gtkgui.start()

    gtk.gdk.threads_enter()
    dep = DepExplorer()
    bardialog = gtk.Dialog(parent=dep,
                           flags=gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT)
    bardialog.set_default_size(400, 50)
    pbar = HobProgressBar()
    bardialog.vbox.pack_start(pbar)
    bardialog.show_all()
    bardialog.connect("delete-event", gtk.main_quit)
    gtk.gdk.threads_leave()

    progress_total = 0
    while True:
        try:
            event = eventHandler.waitEvent(0.25)
            if gtkthread.quit.isSet():
                server.runCommand(["stateStop"])
                break

            if event is None:
                continue

            if isinstance(event, bb.event.CacheLoadStarted):
                progress_total = event.total
                gtk.gdk.threads_enter()
                bardialog.set_title("Loading Cache")
                pbar.update(0)
                gtk.gdk.threads_leave()

            if isinstance(event, bb.event.CacheLoadProgress):
                x = event.current
                gtk.gdk.threads_enter()
                pbar.update(x * 1.0 / progress_total)
                pbar.set_title('')
                gtk.gdk.threads_leave()
                continue

            if isinstance(event, bb.event.CacheLoadCompleted):
                bardialog.hide()
                continue

            if isinstance(event, bb.event.ParseStarted):
                progress_total = event.total
                if progress_total == 0:
                    continue
                gtk.gdk.threads_enter()
                pbar.update(0)
                bardialog.set_title("Processing recipes")

                gtk.gdk.threads_leave()

            if isinstance(event, bb.event.ParseProgress):
                x = event.current
                gtk.gdk.threads_enter()
                pbar.update(x * 1.0 / progress_total)
                pbar.set_title('')
                gtk.gdk.threads_leave()
                continue

            if isinstance(event, bb.event.ParseCompleted):
                bardialog.hide()
                continue

            if isinstance(event, bb.event.DepTreeGenerated):
                gtk.gdk.threads_enter()
                parse(event._depgraph, dep.pkg_model, dep.depends_model)
                gtk.gdk.threads_leave()

            if isinstance(event, bb.command.CommandCompleted):
                continue

            if isinstance(event, bb.command.CommandFailed):
                print("Command execution failed: %s" % event.error)
                return event.exitcode

            if isinstance(event, bb.command.CommandExit):
                return event.exitcode

            if isinstance(event, bb.cooker.CookerExit):
                break

            continue
        except EnvironmentError as ioerror:
            # ignore interrupted io
            if ioerror.args[0] == 4:
                pass
        except KeyboardInterrupt:
            if shutdown == 2:
                print("\nThird Keyboard Interrupt, exit.\n")
                break
            if shutdown == 1:
                print("\nSecond Keyboard Interrupt, stopping...\n")
                server.runCommand(["stateStop"])
            if shutdown == 0:
                print("\nKeyboard Interrupt, closing down...\n")
                server.runCommand(["stateShutdown"])
            shutdown = shutdown + 1
            pass
コード例 #39
0
ファイル: builddetailspage.py プロジェクト: pombredanne/poky
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")