Beispiel #1
0
    def show_load_my_images_dialog(self):
        dialog = ImageSelectionDialog(self.parameters.image_addr,
                                      self.parameters.image_types,
                                      "Open My Images", self,
                                      gtk.FILE_CHOOSER_ACTION_SAVE)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        if response == gtk.RESPONSE_YES:
            if not dialog.image_names:
                lbl = "<b>No selections made</b>\nYou have not made any selections"
                crumbs_dialog = CrumbsMessageDialog(self, lbl,
                                                    gtk.STOCK_DIALOG_INFO)
                button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK)
                HobButton.style_button(button)
                crumbs_dialog.run()
                crumbs_dialog.destroy()
                dialog.destroy()
                return

            self.parameters.image_addr = dialog.image_folder
            self.parameters.image_names = dialog.image_names[:]
            self.switch_page(self.MY_IMAGE_OPENED)

        dialog.destroy()
Beispiel #2
0
 def show_adv_settings_dialog(self):
     dialog = AdvancedSettingDialog(
         title="Settings",
         configuration=copy.deepcopy(self.configuration),
         all_image_types=self.parameters.image_types,
         all_package_formats=self.parameters.all_package_formats,
         all_distros=self.parameters.all_distros,
         all_sdk_machines=self.parameters.all_sdk_machines,
         max_threads=self.parameters.max_threads,
         enable_proxy=self.parameters.enable_proxy,
         parent=self,
         flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR,
     )
     button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
     HobAltButton.style_button(button)
     button = dialog.add_button("Save", gtk.RESPONSE_YES)
     HobButton.style_button(button)
     response = dialog.run()
     settings_changed = False
     if response == gtk.RESPONSE_YES:
         self.parameters.enable_proxy = dialog.enable_proxy
         self.configuration = dialog.configuration
         self.save_defaults()  # remember settings
         settings_changed = dialog.settings_changed
     dialog.destroy()
     return response == gtk.RESPONSE_YES, settings_changed
Beispiel #3
0
 def handler_no_provider_cb(self, running_build, msg):
     dialog = CrumbsMessageDialog(self, msg, gtk.STOCK_DIALOG_INFO)
     button = dialog.add_button("Close", gtk.RESPONSE_OK)
     HobButton.style_button(button)
     dialog.run()
     dialog.destroy()
     self.build_failed()
Beispiel #4
0
 def handler_no_provider_cb(self, running_build, msg):
     dialog = CrumbsMessageDialog(self, msg, gtk.STOCK_DIALOG_INFO)
     button = dialog.add_button("Close", gtk.RESPONSE_OK)
     HobButton.style_button(button)
     dialog.run()
     dialog.destroy()
     self.build_failed()
Beispiel #5
0
 def show_error_dialog(self, msg):
     lbl = "<b>Hob found an error</b>\n"
     dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR, msg)
     button = dialog.add_button("Close", gtk.RESPONSE_OK)
     HobButton.style_button(button)
     response = dialog.run()
     dialog.destroy()
Beispiel #6
0
 def show_adv_settings_dialog(self):
     dialog = AdvancedSettingDialog(
         title="Settings",
         configuration=copy.deepcopy(self.configuration),
         all_image_types=self.parameters.image_types,
         all_package_formats=self.parameters.all_package_formats,
         all_distros=self.parameters.all_distros,
         all_sdk_machines=self.parameters.all_sdk_machines,
         max_threads=self.parameters.max_threads,
         enable_proxy=self.parameters.enable_proxy,
         parent=self,
         flags=gtk.DIALOG_MODAL
         | gtk.DIALOG_DESTROY_WITH_PARENT
         | gtk.DIALOG_NO_SEPARATOR)
     button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
     HobAltButton.style_button(button)
     button = dialog.add_button("Save", gtk.RESPONSE_YES)
     HobButton.style_button(button)
     response = dialog.run()
     settings_changed = False
     if response == gtk.RESPONSE_YES:
         self.parameters.enable_proxy = dialog.enable_proxy
         self.configuration = dialog.configuration
         self.save_defaults()  # remember settings
         settings_changed = dialog.settings_changed
     dialog.destroy()
     return response == gtk.RESPONSE_YES, settings_changed
    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()
Beispiel #8
0
    def show_load_my_images_dialog(self):
        dialog = ImageSelectionDialog(
            self.parameters.image_addr,
            self.parameters.image_types,
            "Open My Images",
            self,
            gtk.FILE_CHOOSER_ACTION_SAVE,
        )
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        if response == gtk.RESPONSE_YES:
            if not dialog.image_names:
                lbl = "<b>No selections made</b>\nYou have not made any selections"
                crumbs_dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
                button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK)
                HobButton.style_button(button)
                crumbs_dialog.run()
                crumbs_dialog.destroy()
                dialog.destroy()
                return

            self.parameters.image_addr = dialog.image_folder
            self.parameters.image_names = dialog.image_names[:]
            self.switch_page(self.MY_IMAGE_OPENED)

        dialog.destroy()
Beispiel #9
0
 def show_error_dialog(self, msg):
     lbl = "<b>Hob found an error</b>\n"
     dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR, msg)
     button = dialog.add_button("Close", gtk.RESPONSE_OK)
     HobButton.style_button(button)
     response = dialog.run()
     dialog.destroy()
    def build_image_clicked_cb(self, button):
        selected_pkgs = self.package_model.get_selected_packages()
        show_missing_pkg_dialog = False
        lbl = "<b>Missing important packages</b>\n\nYour list of included "
        lbl = lbl + " packages is missing:\n\n"
        if not ('eglibc' in selected_pkgs or 'uclibc' in selected_pkgs):
            show_missing_pkg_dialog = True
            lbl = lbl + "-A C library (choose eglibc or uclibc)\n\n"
        if not ('bash' in selected_pkgs or 'busybox'  in selected_pkgs):
            show_missing_pkg_dialog = True
            lbl = lbl + "-A shell provider (choose bash or busybox)\n\n"
        if 'initscripts' not in selected_pkgs:
            show_missing_pkg_dialog = True
            lbl = lbl + "-Initialization scripts (choose initscripts)\n\n"

        if show_missing_pkg_dialog:
            dialog = CrumbsMessageDialog(None, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Build anyway", gtk.RESPONSE_OK)
            tooltip = "Build the image without changing the included packages"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)
            button = dialog.add_button("Edit packages", gtk.RESPONSE_CANCEL)
            tooltip = "Change the list of included packages"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)
            response = dialog.run()
            dialog.destroy()
            if response == gtk.RESPONSE_CANCEL:
                return
        self.builder.build_image()
Beispiel #11
0
    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()
Beispiel #12
0
    def build_image_clicked_cb(self, button):
        selected_pkgs = self.package_model.get_selected_packages()
        show_missing_pkg_dialog = False
        lbl = "<b>Missing important packages</b>\n\nYour list of included "
        lbl = lbl + " packages is missing:\n\n"
        if not ('eglibc' in selected_pkgs or 'uclibc' in selected_pkgs):
            show_missing_pkg_dialog = True
            lbl = lbl + "-A C library (choose eglibc or uclibc)\n\n"
        if not ('bash' in selected_pkgs or 'busybox' in selected_pkgs):
            show_missing_pkg_dialog = True
            lbl = lbl + "-A shell provider (choose bash or busybox)\n\n"
        if 'initscripts' not in selected_pkgs:
            show_missing_pkg_dialog = True
            lbl = lbl + "-Initialization scripts (choose initscripts)\n\n"

        if show_missing_pkg_dialog:
            dialog = CrumbsMessageDialog(None, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Build anyway", gtk.RESPONSE_OK)
            tooltip = "Build the image without changing the included packages"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)
            button = dialog.add_button("Edit packages", gtk.RESPONSE_CANCEL)
            tooltip = "Change the list of included packages"
            button.set_tooltip_text(tooltip)
            HobButton.style_button(button)
            response = dialog.run()
            dialog.destroy()
            if response == gtk.RESPONSE_CANCEL:
                return
        self.builder.build_image()
Beispiel #13
0
 def image_type_checkbutton_clicked_cb(self, button):
     self.set_save_button_state()
     if self.get_num_checked_image_types() == 0:
         # Show an error dialog
         lbl = "<b>Select an image type</b>\n\nYou need to select at least one image type."
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING)
         button = dialog.add_button("OK", gtk.RESPONSE_OK)
         HobButton.style_button(button)
         response = dialog.run()
         dialog.destroy()
 def image_type_checkbutton_clicked_cb(self, button):
     self.set_save_button_state()
     if self.get_num_checked_image_types() == 0:
         # Show an error dialog
         lbl = "<b>Select an image type</b>\n\nYou need to select at least one image type."
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING)
         button = dialog.add_button("OK", gtk.RESPONSE_OK)
         HobButton.style_button(button)
         response = dialog.run()
         dialog.destroy()
Beispiel #15
0
 def show_save_template_dialog(self):
     dialog = gtk.FileChooserDialog("Save Template Files", self, gtk.FILE_CHOOSER_ACTION_SAVE)
     button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
     HobAltButton.style_button(button)
     button = dialog.add_button("Save", gtk.RESPONSE_YES)
     HobButton.style_button(button)
     dialog.set_current_name("hob")
     response = dialog.run()
     if response == gtk.RESPONSE_YES:
         path = dialog.get_filename()
         self.save_template(path)
     dialog.destroy()
Beispiel #16
0
    def show_invalid_input_error_dialog(self):
        lbl = "<b>Invalid characters in image recipe name</b>"
        msg = "Image recipe names should be all lowercase and\n"
        msg += "include only alphanumeric characters. The only\n"
        msg += "special character you can use is the ASCII hyphen (-)."
        dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_ERROR, msg)
        button = dialog.add_button("Close", gtk.RESPONSE_OK)
        HobButton.style_button(button)

        res = dialog.run()
        self.name_entry.grab_focus()
        dialog.destroy()
Beispiel #17
0
 def build_image(self):
     selected_packages = self.package_model.get_selected_packages()
     if not selected_packages:
         lbl = "<b>No selections made</b>\nYou have not made any selections"
         lbl = lbl + " so there isn't anything to bake at this time."
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
         button = dialog.add_button("Close", gtk.RESPONSE_OK)
         HobButton.style_button(button)
         dialog.run()
         dialog.destroy()
         return
     self.generate_image_async()
Beispiel #18
0
 def build_image(self):
     selected_packages = self.package_model.get_selected_packages()
     if not selected_packages:
         lbl = "<b>No selections made</b>\nYou have not made any selections"
         lbl = lbl + " so there isn't anything to bake at this time."
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
         button = dialog.add_button("Close", gtk.RESPONSE_OK)
         HobButton.style_button(button)
         dialog.run()
         dialog.destroy()
         return
     self.generate_image_async(True)
Beispiel #19
0
 def show_save_template_dialog(self):
     dialog = gtk.FileChooserDialog("Save Template Files", self,
                                    gtk.FILE_CHOOSER_ACTION_SAVE)
     button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
     HobAltButton.style_button(button)
     button = dialog.add_button("Save", gtk.RESPONSE_YES)
     HobButton.style_button(button)
     dialog.set_current_name("hob")
     response = dialog.run()
     if response == gtk.RESPONSE_YES:
         path = dialog.get_filename()
         self.save_template(path)
     dialog.destroy()
Beispiel #20
0
    def entry_widget_select_path_cb(self, action, parent, entry):
        dialog = gtk.FileChooserDialog("", parent,
                                       gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        if response == gtk.RESPONSE_YES:
            path = dialog.get_filename()
            entry.set_text(path)

        dialog.destroy()
    def entry_widget_select_path_cb(self, action, parent, entry):
        dialog = gtk.FileChooserDialog("", parent,
                                       gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        text = entry.get_text()
        dialog.set_current_folder(text if len(text) > 0 else os.getcwd())
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        if response == gtk.RESPONSE_YES:
            path = dialog.get_filename()
            entry.set_text(path)

        dialog.destroy()
Beispiel #22
0
    def just_bake(self):
        selected_image = self.recipe_model.get_selected_image()
        selected_packages = self.package_model.get_selected_packages() or []

        # If no base image and no selected packages don't build anything
        if not (selected_packages or selected_image != self.recipe_model.__dummy_image__):
            lbl = "<b>No selections made</b>\nYou have not made any selections"
            lbl = lbl + " so there isn't anything to bake at this time."
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        self.fast_generate_image_async()
Beispiel #23
0
    def select_path_cb(self, action, parent, entry):
        dialog = gtk.FileChooserDialog("", parent,
                                       gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        text = entry.get_text()
        dialog.set_current_folder(text if len(text) > 0 else os.getcwd())
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        if response == gtk.RESPONSE_YES:
            path = dialog.get_filename()
            entry.set_text(path)
            self.image_folder = path
            self.fill_image_store()

        dialog.destroy()
Beispiel #24
0
 def destroy_window_cb(self, widget, event):
     if not self.sensitive:
         return True
     lbl = "<b>Do you really want to exit the Hob image creator?</b>"
     dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
     button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
     HobAltButton.style_button(button)
     button = dialog.add_button("Exit Hob", gtk.RESPONSE_YES)
     HobButton.style_button(button)
     dialog.set_default_response(gtk.RESPONSE_YES)
     response = dialog.run()
     dialog.destroy()
     if response == gtk.RESPONSE_YES:
         gtk.main_quit()
         return False
     else:
         return True
Beispiel #25
0
    def just_bake(self):
        selected_image = self.recipe_model.get_selected_image()
        selected_packages = self.package_model.get_selected_packages() or []

        # If no base image and no selected packages don't build anything
        if not (selected_packages
                or selected_image != self.recipe_model.__custom_image__):
            lbl = "<b>No selections made</b>\nYou have not made any selections"
            lbl = lbl + " so there isn't anything to bake at this time."
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        self.fast_generate_image_async(True)
Beispiel #26
0
    def show_load_template_dialog(self):
        dialog = gtk.FileChooserDialog("Load Template Files", self, gtk.FILE_CHOOSER_ACTION_OPEN)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        filter = gtk.FileFilter()
        filter.set_name("Hob Files")
        filter.add_pattern("*.hob")
        dialog.add_filter(filter)

        response = dialog.run()
        path = None
        if response == gtk.RESPONSE_YES:
            path = dialog.get_filename()
        dialog.destroy()
        return response == gtk.RESPONSE_YES, path
Beispiel #27
0
 def destroy_window_cb(self, widget, event):
     if not self.sensitive:
         return True
     lbl = "<b>Do you really want to exit the Hob image creator?</b>"
     dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
     button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
     HobAltButton.style_button(button)
     button = dialog.add_button("Exit Hob", gtk.RESPONSE_YES)
     HobButton.style_button(button)
     dialog.set_default_response(gtk.RESPONSE_YES)
     response = dialog.run()
     dialog.destroy()
     if response == gtk.RESPONSE_YES:
         gtk.main_quit()
         return False
     else:
         return True
Beispiel #28
0
    def show_load_template_dialog(self):
        dialog = gtk.FileChooserDialog("Load Template Files", self,
                                       gtk.FILE_CHOOSER_ACTION_OPEN)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        filter = gtk.FileFilter()
        filter.set_name("Hob Files")
        filter.add_pattern("*.hob")
        dialog.add_filter(filter)

        response = dialog.run()
        path = None
        if response == gtk.RESPONSE_YES:
            path = dialog.get_filename()
        dialog.destroy()
        return response == gtk.RESPONSE_YES, path
Beispiel #29
0
    def deploy_image(self, image_name):
        if not image_name:
            lbl = "<b>Please select an image to deploy.</b>"
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        dialog = DeployImageDialog(self,
            title = "Hob IoT",
            image = image_name,
            parent = self,
            flags = gtk.DIALOG_MODAL
                    | gtk.DIALOG_DESTROY_WITH_PARENT
                    | gtk.DIALOG_NO_SEPARATOR)
        response = dialog.run()
        dialog.destroy()
Beispiel #30
0
 def show_packages(self, ask=True):
     _, selected_recipes = self.recipe_model.get_selected_recipes()
     if selected_recipes and ask:
         lbl = "<b>Package list may be incomplete!</b>\nDo you want to build selected recipes"
         lbl = lbl + " to get a full list or just view the existing packages?"
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
         button = dialog.add_button("View packages", gtk.RESPONSE_NO)
         HobAltButton.style_button(button)
         button = dialog.add_button("Build packages", gtk.RESPONSE_YES)
         HobButton.style_button(button)
         dialog.set_default_response(gtk.RESPONSE_YES)
         response = dialog.run()
         dialog.destroy()
         if response == gtk.RESPONSE_YES:
             self.generate_packages_async(True)
         else:
             self.switch_page(self.PACKAGE_SELECTION)
     else:
         self.switch_page(self.PACKAGE_SELECTION)
Beispiel #31
0
    def deploy_image(self, image_name):
        if not image_name:
            lbl = "<b>Please select an image to deploy.</b>"
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        dialog = DeployImageDialog(self,
                                   title="Hob IoT",
                                   image=image_name,
                                   parent=self,
                                   flags=gtk.DIALOG_MODAL
                                   | gtk.DIALOG_DESTROY_WITH_PARENT
                                   | gtk.DIALOG_NO_SEPARATOR)
        response = dialog.run()
        dialog.destroy()
Beispiel #32
0
 def show_packages(self, ask=True):
     _, selected_recipes = self.recipe_model.get_selected_recipes()
     if selected_recipes and ask:
         lbl = "<b>Package list may be incomplete!</b>\nDo you want to build selected recipes"
         lbl = lbl + " to get a full list or just view the existing packages?"
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
         button = dialog.add_button("View packages", gtk.RESPONSE_NO)
         HobAltButton.style_button(button)
         button = dialog.add_button("Build packages", gtk.RESPONSE_YES)
         HobButton.style_button(button)
         dialog.set_default_response(gtk.RESPONSE_YES)
         response = dialog.run()
         dialog.destroy()
         if response == gtk.RESPONSE_YES:
             self.generate_packages_async()
         else:
             self.switch_page(self.PACKAGE_SELECTION)
     else:
         self.switch_page(self.PACKAGE_SELECTION)
    def response_cb(self, dialog, response_id):
        if response_id == gtk.RESPONSE_YES:
            # Check that all proxy entries have a corresponding port
            for proxy, port in zip(self.all_proxy_addresses,
                                   self.all_proxy_ports):
                if proxy.get_text() and not port.get_text():
                    lbl = "<b>Enter all port numbers</b>\n\n"
                    msg = "Proxy servers require a port number. Please make sure you have entered a port number for each proxy server."
                    dialog = CrumbsMessageDialog(self, lbl,
                                                 gtk.STOCK_DIALOG_WARNING, msg)
                    button = dialog.add_button("Close", gtk.RESPONSE_OK)
                    HobButton.style_button(button)
                    response = dialog.run()
                    dialog.destroy()
                    self.emit_stop_by_name("response")
                    return

        self.configuration.dldir = self.dldir_text.get_text()
        self.configuration.sstatedir = self.sstatedir_text.get_text()
        self.configuration.sstatemirror = ""
        for mirror in self.sstatemirrors_list:
            if mirror[1] != "" and mirror[2].startswith("file://"):
                if mirror[1].endswith("\\1"):
                    smirror = mirror[2] + " " + mirror[1] + " \\n "
                else:
                    smirror = mirror[2] + " " + mirror[1] + "\\1 \\n "
                self.configuration.sstatemirror += smirror
        self.configuration.bbthread = self.bb_spinner.get_value_as_int()
        self.configuration.pmake = self.pmake_spinner.get_value_as_int()
        self.save_proxy_data()
        self.configuration.extra_setting = {}
        it = self.setting_store.get_iter_first()
        while it:
            key = self.setting_store.get_value(it, 0)
            value = self.setting_store.get_value(it, 1)
            self.configuration.extra_setting[key] = value
            it = self.setting_store.iter_next(it)

        md5 = self.config_md5()
        self.settings_changed = (self.md5 != md5)
        self.proxy_settings_changed = (self.proxy_md5 !=
                                       self.config_proxy_md5())
Beispiel #34
0
 def show_layer_selection_dialog(self):
     dialog = LayerSelectionDialog(
         title="Layers",
         layers=copy.deepcopy(self.configuration.layers),
         all_layers=self.parameters.all_layers,
         parent=self,
         flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR,
     )
     button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
     HobAltButton.style_button(button)
     button = dialog.add_button("OK", gtk.RESPONSE_YES)
     HobButton.style_button(button)
     response = dialog.run()
     if response == gtk.RESPONSE_YES:
         self.configuration.layers = dialog.layers
         self.save_defaults()  # remember layers
         # DO refresh layers
         if dialog.layers_changed:
             self.update_config_async()
     dialog.destroy()
Beispiel #35
0
 def show_layer_selection_dialog(self):
     dialog = LayerSelectionDialog(title="Layers",
                                   layers=copy.deepcopy(
                                       self.configuration.layers),
                                   all_layers=self.parameters.all_layers,
                                   parent=self,
                                   flags=gtk.DIALOG_MODAL
                                   | gtk.DIALOG_DESTROY_WITH_PARENT
                                   | gtk.DIALOG_NO_SEPARATOR)
     button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
     HobAltButton.style_button(button)
     button = dialog.add_button("OK", gtk.RESPONSE_YES)
     HobButton.style_button(button)
     response = dialog.run()
     if response == gtk.RESPONSE_YES:
         self.configuration.layers = dialog.layers
         self.save_defaults()  # remember layers
         # DO refresh layers
         if dialog.layers_changed:
             self.update_config_async()
     dialog.destroy()
    def response_cb(self, dialog, response_id):
        if response_id == gtk.RESPONSE_YES:
            if self.proxy_checkbox.get_active():
                # Check that all proxy entries have a corresponding port
                for proxy, port in zip(self.all_proxy_addresses, self.all_proxy_ports):
                    if proxy.get_text() and not port.get_text():
                        lbl = "<b>Enter all port numbers</b>"
                        msg = "Proxy servers require a port number. Please make sure you have entered a port number for each proxy server."
                        dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_WARNING, msg)
                        button = dialog.add_button("Close", gtk.RESPONSE_OK)
                        HobButton.style_button(button)
                        response = dialog.run()
                        dialog.destroy()
                        self.emit_stop_by_name("response")
                        return

        self.configuration.dldir = self.dldir_text.get_text()
        self.configuration.sstatedir = self.sstatedir_text.get_text()
        self.configuration.sstatemirror = ""
        for mirror in self.sstatemirrors_list:
            if mirror[1] != "" and mirror[2].startswith("file://"):
                if mirror[1].endswith("\\1"):
                    smirror = mirror[2] + " " + mirror[1] + " \\n "
                else:
                    smirror = mirror[2] + " " + mirror[1] + "\\1 \\n "
                self.configuration.sstatemirror += smirror
        self.configuration.bbthread = self.bb_spinner.get_value_as_int()
        self.configuration.pmake = self.pmake_spinner.get_value_as_int()
        self.save_proxy_data()
        self.configuration.extra_setting = {}
        it = self.setting_store.get_iter_first()
        while it:
            key = self.setting_store.get_value(it, 0)
            value = self.setting_store.get_value(it, 1)
            self.configuration.extra_setting[key] = value
            it = self.setting_store.iter_next(it)

        md5 = self.config_md5()
        self.settings_changed = self.md5 != md5
        self.proxy_settings_changed = self.proxy_md5 != self.config_proxy_md5()
Beispiel #37
0
    def runqemu_image(self, image_name):
        if not image_name:
            lbl = "<b>Please select an image to launch in QEMU.</b>"
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        kernel_name, kernels_number = self.get_kernel_file_name(self.parameters.image_addr)
        if not kernel_name or kernels_number > 1:
            dialog = gtk.FileChooserDialog("Load Kernel Files", self,
                                           gtk.FILE_CHOOSER_ACTION_SAVE)
            button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
            HobAltButton.style_button(button)
            button = dialog.add_button("Open", gtk.RESPONSE_YES)
            HobButton.style_button(button)
            filter = gtk.FileFilter()
            filter.set_name("Kernel Files")
            filter.add_pattern("*.bin")
            dialog.add_filter(filter)

            dialog.set_current_folder(self.parameters.image_addr)

            response = dialog.run()
            if response == gtk.RESPONSE_YES:
                kernel_path = dialog.get_filename()
                image_path = os.path.join(self.parameters.image_addr, image_name)
            dialog.destroy()

        elif kernel_name:
            kernel_path = os.path.join(self.parameters.image_addr, kernel_name)
            image_path = os.path.join(self.parameters.image_addr, image_name)
            response = gtk.RESPONSE_YES

        if response == gtk.RESPONSE_YES:
            source_env_path = os.path.join(self.parameters.core_base, "oe-init-build-env")
            tmp_path = self.parameters.tmpdir
            cmdline = bb.ui.crumbs.utils.which_terminal()
            if os.path.exists(image_path) and os.path.exists(kernel_path) \
               and os.path.exists(source_env_path) and os.path.exists(tmp_path) \
               and cmdline:
                cmdline += "\' bash -c \"export OE_TMPDIR=" + tmp_path + "; "
                cmdline += "source " + source_env_path + " " + os.getcwd() + "; "
                cmdline += "runqemu " + kernel_path + " " + image_path + "\"\'"
                subprocess.Popen(shlex.split(cmdline))
            else:
                lbl = "<b>Path error</b>\nOne of your paths is wrong,"
                lbl = lbl + " please make sure the following paths exist:\n"
                lbl = lbl + "image path:" + image_path + "\n"
                lbl = lbl + "kernel path:" + kernel_path + "\n"
                lbl = lbl + "source environment path:" + source_env_path + "\n"
                lbl = lbl + "tmp path: " + tmp_path + "."
                lbl = lbl + "You may be missing either xterm or vte for terminal services."
                dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR)
                button = dialog.add_button("Close", gtk.RESPONSE_OK)
                HobButton.style_button(button)
                dialog.run()
                dialog.destroy()
Beispiel #38
0
    def show_load_kernel_dialog(self):
        dialog = gtk.FileChooserDialog("Load Kernel Files", self,
                                       gtk.FILE_CHOOSER_ACTION_SAVE)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        filter = gtk.FileFilter()
        filter.set_name("Kernel Files")
        filter.add_pattern("*.bin")
        dialog.add_filter(filter)

        dialog.set_current_folder(self.parameters.image_addr)

        response = dialog.run()
        kernel_path = ""
        if response == gtk.RESPONSE_YES:
            kernel_path = dialog.get_filename()

        dialog.destroy()

        return kernel_path
Beispiel #39
0
    def show_load_kernel_dialog(self):
        dialog = gtk.FileChooserDialog("Load Kernel Files", self,
                                       gtk.FILE_CHOOSER_ACTION_SAVE)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        filter = gtk.FileFilter()
        filter.set_name("Kernel Files")
        filter.add_pattern("*.bin")
        dialog.add_filter(filter)

        dialog.set_current_folder(self.parameters.image_addr)

        response = dialog.run()
        kernel_path = ""
        if response == gtk.RESPONSE_YES:
            kernel_path = dialog.get_filename()

        dialog.destroy()

        return kernel_path
Beispiel #40
0
 def stop_build(self):
     if self.stopping:
         lbl = "<b>Force Stop build?</b>\nYou've already selected Stop once,"
         lbl = lbl + " would you like to 'Force Stop' the build?\n\n"
         lbl = lbl + "This will stop the build as quickly as possible but may"
         lbl = lbl + " well leave your build directory in an  unusable state"
         lbl = lbl + " that requires manual steps to fix.\n"
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING)
         button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
         HobAltButton.style_button(button)
         button = dialog.add_button("Force Stop", gtk.RESPONSE_YES)
         HobButton.style_button(button)
     else:
         lbl = "<b>Stop build?</b>\n\nAre you sure you want to stop this"
         lbl = lbl + " build?\n\n'Stop' will stop the build as soon as all in"
         lbl = lbl + " progress build tasks are finished. However if a"
         lbl = lbl + " lengthy compilation phase is in progress this may take"
         lbl = lbl + " some time.\n\n"
         lbl = lbl + "'Force Stop' will stop the build as quickly as"
         lbl = lbl + " possible but may well leave your build directory in an"
         lbl = lbl + " unusable state that requires manual steps to fix."
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING)
         button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
         HobAltButton.style_button(button)
         button = dialog.add_button("Force stop", gtk.RESPONSE_YES)
         HobAltButton.style_button(button)
         button = dialog.add_button("Stop", gtk.RESPONSE_OK)
         HobButton.style_button(button)
     response = dialog.run()
     dialog.destroy()
     if response != gtk.RESPONSE_CANCEL:
         self.stopping = True
     if response == gtk.RESPONSE_OK:
         self.build_details_page.progress_bar.set_stop_title(
             "Stopping the build....")
         self.build_details_page.progress_bar.set_rcstyle("stop")
         self.cancel_build_sync()
     elif response == gtk.RESPONSE_YES:
         self.cancel_build_sync(True)
Beispiel #41
0
    def runqemu_image(self, image_name, kernel_name):
        if not image_name or not kernel_name:
            lbl = "<b>Please select an %s to launch in QEMU.</b>" % (
                "kernel" if image_name else "image")
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        kernel_path = os.path.join(self.parameters.image_addr, kernel_name)
        image_path = os.path.join(self.parameters.image_addr, image_name)

        source_env_path = os.path.join(self.parameters.core_base,
                                       "oe-init-build-env")
        tmp_path = self.parameters.tmpdir
        cmdline = bb.ui.crumbs.utils.which_terminal()
        if os.path.exists(image_path) and os.path.exists(kernel_path) \
           and os.path.exists(source_env_path) and os.path.exists(tmp_path) \
           and cmdline:
            cmdline += "\' bash -c \"export OE_TMPDIR=" + tmp_path + "; "
            cmdline += "source " + source_env_path + " " + os.getcwd() + "; "
            cmdline += "runqemu " + kernel_path + " " + image_path + "\"\'"
            subprocess.Popen(shlex.split(cmdline))
        else:
            lbl = "<b>Path error</b>\nOne of your paths is wrong,"
            lbl = lbl + " please make sure the following paths exist:\n"
            lbl = lbl + "image path:" + image_path + "\n"
            lbl = lbl + "kernel path:" + kernel_path + "\n"
            lbl = lbl + "source environment path:" + source_env_path + "\n"
            lbl = lbl + "tmp path: " + tmp_path + "."
            lbl = lbl + "You may be missing either xterm or vte for terminal services."
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
Beispiel #42
0
    def layer_widget_add_clicked_cb(self, action, layer_store, parent):
        dialog = gtk.FileChooserDialog("Add new layer", parent,
                                       gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        label = gtk.Label("Select the layer you wish to add")
        label.show()
        dialog.set_extra_widget(label)
        response = dialog.run()
        path = dialog.get_filename()
        dialog.destroy()

        lbl = "<b>Error</b>"
        msg = "Unable to load layer <i>%s</i> because " % path
        if response == gtk.RESPONSE_YES:
            import os
            import os.path
            layers = []
            it = layer_store.get_iter_first()
            while it:
                layers.append(layer_store.get_value(it, 0))
                it = layer_store.iter_next(it)

            if not path:
                msg += "it is an invalid path."
            elif not os.path.exists(path+"/conf/layer.conf"):
                msg += "there is no layer.conf inside the directory."
            elif path in layers:
                msg += "it is already in loaded layers."
            else:
                layer_store.append([path])
                return
            dialog = CrumbsMessageDialog(parent, lbl, gtk.MESSAGE_ERROR, msg)
            dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_OK)
            response = dialog.run()
            dialog.destroy()
Beispiel #43
0
 def stop_build(self):
     if self.stopping:
         lbl = "<b>Force Stop build?</b>\nYou've already selected Stop once,"
         lbl = lbl + " would you like to 'Force Stop' the build?\n\n"
         lbl = lbl + "This will stop the build as quickly as possible but may"
         lbl = lbl + " well leave your build directory in an  unusable state"
         lbl = lbl + " that requires manual steps to fix.\n"
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING)
         button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
         HobAltButton.style_button(button)
         button = dialog.add_button("Force Stop", gtk.RESPONSE_YES)
         HobButton.style_button(button)
     else:
         lbl = "<b>Stop build?</b>\n\nAre you sure you want to stop this"
         lbl = lbl + " build?\n\n'Stop' will stop the build as soon as all in"
         lbl = lbl + " progress build tasks are finished. However if a"
         lbl = lbl + " lengthy compilation phase is in progress this may take"
         lbl = lbl + " some time.\n\n"
         lbl = lbl + "'Force Stop' will stop the build as quickly as"
         lbl = lbl + " possible but may well leave your build directory in an"
         lbl = lbl + " unusable state that requires manual steps to fix."
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING)
         button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
         HobAltButton.style_button(button)
         button = dialog.add_button("Force stop", gtk.RESPONSE_YES)
         HobAltButton.style_button(button)
         button = dialog.add_button("Stop", gtk.RESPONSE_OK)
         HobButton.style_button(button)
     response = dialog.run()
     dialog.destroy()
     if response != gtk.RESPONSE_CANCEL:
         self.stopping = True
     if response == gtk.RESPONSE_OK:
         self.build_details_page.progress_bar.set_stop_title("Stopping the build....")
         self.build_details_page.progress_bar.set_rcstyle("stop")
         self.cancel_build_sync()
     elif response == gtk.RESPONSE_YES:
         self.cancel_build_sync(True)
Beispiel #44
0
    def deploy_image(self, image_name):
        if not image_name:
            lbl = "<b>Please select an image to deploy.</b>"
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        image_path = os.path.join(self.parameters.image_addr, image_name)
        dialog = DeployImageDialog(title="Usb Image Maker",
                                   image_path=image_path,
                                   parent=self,
                                   flags=gtk.DIALOG_MODAL
                                   | gtk.DIALOG_DESTROY_WITH_PARENT
                                   | gtk.DIALOG_NO_SEPARATOR)
        button = dialog.add_button("Close", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Make usb image", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        dialog.destroy()
Beispiel #45
0
    def deploy_image(self, image_name):
        if not image_name:
            lbl = "<b>Please select an image to deploy.</b>"
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        image_path = os.path.join(self.parameters.image_addr, image_name)
        dialog = DeployImageDialog(
            title="Usb Image Maker",
            image_path=image_path,
            parent=self,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR,
        )
        button = dialog.add_button("Close", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Make usb image", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        response = dialog.run()
        dialog.destroy()
Beispiel #46
0
    def runqemu_image(self, image_name, kernel_name):
        if not image_name or not kernel_name:
            lbl = "<b>Please select an %s to launch in QEMU.</b>" % ("kernel" if image_name else "image")
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        kernel_path = os.path.join(self.parameters.image_addr, kernel_name)
        image_path = os.path.join(self.parameters.image_addr, image_name)

        source_env_path = os.path.join(self.parameters.core_base, "oe-init-build-env")
        tmp_path = self.parameters.tmpdir
        cmdline = bb.ui.crumbs.utils.which_terminal()
        if os.path.exists(image_path) and os.path.exists(kernel_path) \
           and os.path.exists(source_env_path) and os.path.exists(tmp_path) \
           and cmdline:
            cmdline += "\' bash -c \"export OE_TMPDIR=" + tmp_path + "; "
            cmdline += "source " + source_env_path + " " + os.getcwd() + "; "
            cmdline += "runqemu " + kernel_path + " " + image_path + "\"\'"
            subprocess.Popen(shlex.split(cmdline))
        else:
            lbl = "<b>Path error</b>\nOne of your paths is wrong,"
            lbl = lbl + " please make sure the following paths exist:\n"
            lbl = lbl + "image path:" + image_path + "\n"
            lbl = lbl + "kernel path:" + kernel_path + "\n"
            lbl = lbl + "source environment path:" + source_env_path + "\n"
            lbl = lbl + "tmp path: " + tmp_path + "."
            lbl = lbl + "You may be missing either xterm or vte for terminal services."
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
Beispiel #47
0
    def runqemu_image(self, image_name):
        if not image_name:
            lbl = "<b>Please select an image to launch in QEMU.</b>"
            dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
            button = dialog.add_button("Close", gtk.RESPONSE_OK)
            HobButton.style_button(button)
            dialog.run()
            dialog.destroy()
            return

        dialog = gtk.FileChooserDialog("Load Kernel Files", self,
                                       gtk.FILE_CHOOSER_ACTION_SAVE)
        button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
        HobAltButton.style_button(button)
        button = dialog.add_button("Open", gtk.RESPONSE_YES)
        HobButton.style_button(button)
        filter = gtk.FileFilter()
        filter.set_name("Kernel Files")
        filter.add_pattern("*.bin")
        dialog.add_filter(filter)

        dialog.set_current_folder(self.parameters.image_addr)

        response = dialog.run()
        if response == gtk.RESPONSE_YES:
            kernel_path = dialog.get_filename()
            image_path = os.path.join(self.parameters.image_addr, image_name)
        dialog.destroy()

        if response == gtk.RESPONSE_YES:
            source_env_path = os.path.join(self.parameters.core_base,
                                           "oe-init-build-env")
            tmp_path = self.parameters.tmpdir
            cmdline = bb.ui.crumbs.utils.which_terminal()
            if os.path.exists(image_path) and os.path.exists(kernel_path) \
               and os.path.exists(source_env_path) and os.path.exists(tmp_path) \
               and cmdline:
                cmdline += "\' bash -c \"export OE_TMPDIR=" + tmp_path + "; "
                cmdline += "source " + source_env_path + " " + os.getcwd(
                ) + "; "
                cmdline += "runqemu " + kernel_path + " " + image_path + "\"\'"
                subprocess.Popen(shlex.split(cmdline))
            else:
                lbl = "<b>Path error</b>\nOne of your paths is wrong,"
                lbl = lbl + " please make sure the following paths exist:\n"
                lbl = lbl + "image path:" + image_path + "\n"
                lbl = lbl + "kernel path:" + kernel_path + "\n"
                lbl = lbl + "source environment path:" + source_env_path + "\n"
                lbl = lbl + "tmp path: " + tmp_path + "."
                lbl = lbl + "You may be missing either xterm or vte for terminal services."
                dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR)
                button = dialog.add_button("Close", gtk.RESPONSE_OK)
                HobButton.style_button(button)
                dialog.run()
                dialog.destroy()
Beispiel #48
0
    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()
Beispiel #49
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()
    def show_builded_images_dialog(self, widget, primary_action=""):
        title = primary_action if primary_action else "Your builded images"
        dialog = CrumbsDialog(title, self.builder,
                              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        dialog.set_border_width(12)

        label = gtk.Label()
        label.set_use_markup(True)
        label.set_alignment(0.0, 0.5)
        label.set_padding(12,0)
        if primary_action == "Run image":
            label.set_markup("<span font_desc='12'>Select the image file you want to run:</span>")
        elif primary_action == "Deploy image":
            label.set_markup("<span font_desc='12'>Select the image file you want to deploy:</span>")
        else:
            label.set_markup("<span font_desc='12'>Select the image file you want to %s</span>" % primary_action)
        dialog.vbox.pack_start(label, expand=False, fill=False)

        # filter created images as action attribution (deploy or run)
        action_attr = ""
        action_images = []
        for fileitem in self.image_store:
            action_attr = fileitem['action_attr']
            if  (action_attr == 'run' and primary_action == "Run image") \
             or (action_attr == 'deploy' and primary_action == "Deploy image"):
                action_images.append(fileitem)

        # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file.
        # assume that there does not both have 'deploy' and 'runnable' files in the same building result
        # in possible as design.
        curr_row = 0
        rows = (len(action_images)) if len(action_images) < 10 else 10
        table = gtk.Table(rows, 10, True)
        table.set_row_spacings(6)
        table.set_col_spacing(0, 12)
        table.set_col_spacing(5, 12)

        sel_parent_btn = None
        for fileitem in action_images:
            sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
            sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
            sel_btn.set_active(fileitem['is_toggled'])
            sel_btn.connect('toggled', self.table_selected_cb, fileitem)
            if curr_row < 10:
                table.attach(sel_btn, 0, 4, curr_row, curr_row + 1, xpadding=24)
            else:
                table.attach(sel_btn, 5, 9, curr_row - 10, curr_row - 9, xpadding=24)
            curr_row += 1

        dialog.vbox.pack_start(table, expand=False, fill=False, padding=6)

        button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
        HobAltButton.style_button(button)

        if primary_action:
            button = dialog.add_button(primary_action, gtk.RESPONSE_YES)
            HobButton.style_button(button)

        dialog.show_all()

        response = dialog.run()
        dialog.destroy()

        if response != gtk.RESPONSE_YES:
            return

        for fileitem in self.image_store:
            if fileitem['is_toggled']:
                if fileitem['action_attr'] == 'run':
                    self.builder.runqemu_image(fileitem['name'], self.sel_kernel)
                elif fileitem['action_attr'] == 'deploy':
                    self.builder.deploy_image(fileitem['name'])
Beispiel #51
0
    def show_builded_images_dialog(self, widget, primary_action=""):
        title = primary_action if primary_action else "Your builded images"
        dialog = CrumbsDialog(
            title, self.builder,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        dialog.set_border_width(12)

        label = gtk.Label()
        label.set_use_markup(True)
        label.set_alignment(0.0, 0.5)
        label.set_padding(12, 0)
        if primary_action == "Run image":
            label.set_markup(
                "<span font_desc='12'>Select the image file you want to run:</span>"
            )
        elif primary_action == "Deploy image":
            label.set_markup(
                "<span font_desc='12'>Select the image file you want to deploy:</span>"
            )
        else:
            label.set_markup(
                "<span font_desc='12'>Select the image file you want to %s</span>"
                % primary_action)
        dialog.vbox.pack_start(label, expand=False, fill=False)

        # filter created images as action attribution (deploy or run)
        action_attr = ""
        action_images = []
        for fileitem in self.image_store:
            action_attr = fileitem['action_attr']
            if  (action_attr == 'run' and primary_action == "Run image") \
             or (action_attr == 'deploy' and primary_action == "Deploy image"):
                action_images.append(fileitem)

        # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file.
        # assume that there does not both have 'deploy' and 'runnable' files in the same building result
        # in possible as design.
        curr_row = 0
        rows = (len(action_images)) if len(action_images) < 10 else 10
        table = gtk.Table(rows, 10, True)
        table.set_row_spacings(6)
        table.set_col_spacing(0, 12)
        table.set_col_spacing(5, 12)

        sel_parent_btn = None
        for fileitem in action_images:
            sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
            sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
            sel_btn.set_active(fileitem['is_toggled'])
            sel_btn.connect('toggled', self.table_selected_cb, fileitem)
            if curr_row < 10:
                table.attach(sel_btn,
                             0,
                             4,
                             curr_row,
                             curr_row + 1,
                             xpadding=24)
            else:
                table.attach(sel_btn,
                             5,
                             9,
                             curr_row - 10,
                             curr_row - 9,
                             xpadding=24)
            curr_row += 1

        dialog.vbox.pack_start(table, expand=False, fill=False, padding=6)

        button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
        HobAltButton.style_button(button)

        if primary_action:
            button = dialog.add_button(primary_action, gtk.RESPONSE_YES)
            HobButton.style_button(button)

        dialog.show_all()

        response = dialog.run()
        dialog.destroy()

        if response != gtk.RESPONSE_YES:
            return

        for fileitem in self.image_store:
            if fileitem['is_toggled']:
                if fileitem['action_attr'] == 'run':
                    self.builder.runqemu_image(fileitem['name'],
                                               self.sel_kernel)
                elif fileitem['action_attr'] == 'deploy':
                    self.builder.deploy_image(fileitem['name'])