V2 hob2: some tweak and add a standalone deploy image tool
cover V2 hob2: some tweak and add a standalone deploy image tool
Hi Darren,
Thanks for your detailed reivew.
V2 update:
1. break up the commit about hig.py
2. some text tweak
3. remove the gtk version check
4. rename the standalone tool
V1:
These 2 patches try to add a standalone deploy image tool using current codes. It should be launched by run the absolute path to bitbake/bin/bitbake-deployimage, I'll add a shell script to wrap it under script directory.
Regards,
Kai
The following changes since commit de4cdfd6bc1280ac7ac0559b87734d26294ef773:
documentation/kernel-manual/kernel-how-to.xml: Updated to kernel 3.4 (2012-05-31 21:16:55 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib kangkai/distro
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/distro
Kang Kai (6):
ui/crumbs/utils.py: import module bb ui/crumbs/hig.py: fix run time error ui/crumbs/hig.py: remove extra spaces ui/crumbs/hig.py: check deploy process return value
hob2: update DeployImageDialog for seperated tool
hob2: create a standalone deploy image tool
bitbake/bin/image-writer | 120 +++++++++++++++++++++++++++++++++++++ bitbake/lib/bb/ui/crumbs/hig.py | 88 ++++++++++++++++++++++----- bitbake/lib/bb/ui/crumbs/utils.py | 1 + 3 files changed, 194 insertions(+), 15 deletions(-) create mode 100755 bitbake/bin/image-writer
Signature · 1 line
1.7.5.4
PATCH 1/6 ui/crumbs/utils.py: import module bb
When I try to call function which_terminal() of utils.py directly, it complains NameError: global name 'bb' is not defined
So import module bb
--- bitbake/lib/bb/ui/crumbs/utils.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
@@ -22,6 +22,7 @@ # bitbake which will allow more flexibility. import os +import bb def which_terminal(): term = bb.utils.which(os.environ["PATH"], "xterm")
Signature · 1 line
1.7.5.4
PATCH 2/6 ui/crumbs/hig.py: fix run time error
In reply to Kang KaiCommit 094742bed2fc01d55f572da946fcfa7a48521401 re-implement the function popen_read(). If there is no USB device, it crashes with "ExecutionError: Execution of 'ls /dev/disk/by-id/usb*' failed with exit code 2:"
Replace popen_read() way with glob module to get the USB devices.
--- bitbake/lib/bb/ui/crumbs/hig.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
bitbake/lib/bb/ui/crumbs/hig.py +2 -1
@@ -20,6 +20,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import glob import gtk import gobject import hashlib
@@ -806,7 +807,7 @@ class DeployImageDialog (CrumbsDialog): def find_all_usb_devices(self): usb_devs = [ os.readlink(u) - for u in self.popen_read('ls /dev/disk/by-id/usb*').split() + 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 ]
Signature · 1 line
1.7.5.4
PATCH 3/6 ui/crumbs/hig.py: remove extra spaces
In reply to Kang KaiRemove extra spaces at the end of line or blank line.
--- bitbake/lib/bb/ui/crumbs/hig.py | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
bitbake/lib/bb/ui/crumbs/hig.py +5 -5
@@ -64,7 +64,7 @@ class CrumbsMessageDialog(CrumbsDialog): """ def __init__(self, parent=None, label="", icon=gtk.STOCK_INFO): super(CrumbsMessageDialog, self).__init__("", parent, gtk.DIALOG_DESTROY_WITH_PARENT) - + self.set_border_width(6) self.vbox.set_property("spacing", 12) self.action_area.set_property("spacing", 12)
@@ -208,7 +208,7 @@ class AdvancedSettingDialog (CrumbsDialog): hbox.pack_start(port_entry, expand=False, fill=False) details_button = HobAltButton("Details") - details_button.connect("clicked", self.details_cb, parent, protocol) + details_button.connect("clicked", self.details_cb, parent, protocol) hbox.pack_start(details_button, expand=False, fill=False) hbox.show_all()
@@ -1036,7 +1036,7 @@ class LayerSelectionDialog (CrumbsDialog): # create visual elements on the dialog self.create_visual_elements() self.connect("response", self.response_cb) - + def create_visual_elements(self): layer_widget, self.layer_store = self.gen_layer_widget(self.layers, self.all_layers, self, None) layer_widget.set_size_request(450, 250)
@@ -1211,7 +1211,7 @@ class ImageSelectionDialog (CrumbsDialog): if f.endswith('.' + real_image_type): imageset.add(f.rsplit('.' + real_image_type)[0].rsplit('.rootfs')[0]) self.image_list.append(f) - + for image in imageset: self.image_store.set(self.image_store.append(), 0, image, 1, False)
@@ -1227,7 +1227,7 @@ class ImageSelectionDialog (CrumbsDialog): for f in self.image_list: if f.startswith(self.image_store[path][0] + '.'): self.image_names.append(f) - break + break iter = self.image_store.iter_next(iter) class ProxyDetailsDialog (CrumbsDialog):
Signature · 1 line
1.7.5.4
PATCH 4/6 ui/crumbs/hig.py: check deploy process return value
In reply to Kang KaiUpdate function response_cb of DeployImageDialog to get deploy process return value. According the return value tell user that deploy image successfully or not.
--- bitbake/lib/bb/ui/crumbs/hig.py | 32 +++++++++++++++++++++++++++++--- 1 files changed, 29 insertions(+), 3 deletions(-)
bitbake/lib/bb/ui/crumbs/hig.py +29 -3
@@ -827,12 +827,38 @@ class DeployImageDialog (CrumbsDialog): def response_cb(self, dialog, response_id): if response_id == gtk.RESPONSE_YES: + lbl = '' combo_item = self.usb_combo.get_active_text() - if combo_item and combo_item != self.__dummy_usb__: + if combo_item and combo_item != self.__dummy_usb__ and self.image_path: cmdline = bb.ui.crumbs.utils.which_terminal() if cmdline: - cmdline += "\"sudo dd if=" + self.image_path + " of=" + combo_item + "\"" - bb.process.Popen(shlex.split(cmdline)) + tmpname = os.tmpnam() + cmdline += "\"sudo dd if=" + self.image_path + \ + " of=" + combo_item + "; echo $? > " + tmpname + "\"" + deploy_process = bb.process.Popen(shlex.split(cmdline)) + deploy_process.wait() + + # if file tmpname not exists, that means there is something wrong with xterm + # user can get the error message from xterm so no more warning need. + if os.path.exists(tmpname): + tmpfile = open(tmpname) + if int(tmpfile.readline().strip()) == 0: + lbl = "<b>Deploy image successfully</b>" + else: + lbl = "<b>Deploy image failed</b>\nPlease try again." + tmpfile.close() + os.remove(tmpname) + else: + if not self.image_path: + lbl = "<b>No selection made</b>\nYou have not selected an image to deploy" + else: + lbl = "<b>No selection made</b>\nYou have not selected USB device" + if len(lbl): + 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() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction)
Signature · 1 line
1.7.5.4
Re: [PATCH 4/6] ui/crumbs/hig.py: check deploy process return value
Hi Kang,
A couple comments below...
Quoted 15 lines · Kang Kai
Update function
response_cbof DeployImageDialog to get deploy process return value. According the return value tell user that deploy image successfully or not.Signed-off-by Kang Kai <[email protected]>--- bitbake/lib/bb/ui/crumbs/hig.py | 32 +++++++++++++++++++++++++++++--- 1 files changed, 29 insertions(+), 3 deletions(-)bitbake/lib/bb/ui/crumbs/hig.py +0
-0@@ -827,12 +827,38 @@ class DeployImageDialog (CrumbsDialog):
bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 835
Quoted 10 lines
bitbake/lib/bb/ui/crumbs/hig.py +2
-3def response_cb(self, dialog, response_id): if response_id == gtk.RESPONSE_YES: + lbl = '' combo_item = self.usb_combo.get_active_text() - if combo_item and combo_item != self.__dummy_usb__: + if combo_item and combo_item != self.__dummy_usb__ and self.image_path: cmdline = bb.ui.crumbs.utils.which_terminal() if cmdline: - cmdline += "\"sudo dd if=" + self.image_path + " of=" + combo_item + "\"" - bb.process.Popen(shlex.split(cmdline))
This should be subprocess.call()
bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 846
Quoted 12 lines
bitbake/lib/bb/ui/crumbs/hig.py +12
-0+ tmpname = os.tmpnam() + cmdline += "\"sudo dd if=" + self.image_path + \ + " of=" + combo_item + "; echo $? > " + tmpname + "\"" + deploy_process = bb.process.Popen(shlex.split(cmdline)) + deploy_process.wait() + + # if file tmpname not exists, that means there is something wrong with xterm + # user can get the error message from xterm so no more warning need. + if os.path.exists(tmpname): + tmpfile = open(tmpname) + if int(tmpfile.readline().strip()) == 0: + lbl = "<b>Deploy image successfully</b>"
"<b>Deployed image successfully.</b>"
bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 848
Quoted 2 lines
bitbake/lib/bb/ui/crumbs/hig.py +2
-0+ else: + lbl = "<b>Deploy image failed</b>\nPlease try again."
"<b>Failed to deploy image.</b>"
As to "Please try again." Why would the user have any expectation of a different result? Is there something we can tell them about the reason for the failure?
bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 853
Quoted 5 lines
bitbake/lib/bb/ui/crumbs/hig.py +5
-0+ tmpfile.close() + os.remove(tmpname) + else: + if not self.image_path: + lbl = "<b>No selection made</b>\nYou have not selected an image to deploy"
Missing periods.
bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 855
Quoted 2 lines
bitbake/lib/bb/ui/crumbs/hig.py +2
-0+ else: + lbl = "<b>No selection made</b>\nYou have not selected USB device"
Missing periods. Missing article:
"<b>No selection made.</b>\nYou have not selected a USB device."
Quoted 9 lines
bitbake/lib/bb/ui/crumbs/hig.py +6
-0+ if len(lbl): + 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() def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction)
Signature · 3 lines
Darren Hart Intel Open Source Technology Center Yocto Project - Linux Kernel
PATCH 5/6 hob2: update DeployImageDialog for seperated tool
In reply to Kang KaiPart of [Yocto 2388]
Update class DeployImageDialog to get ready for a standalone deploy image tool. The standalone tool can be run directly without hob, and add a button to select image file. So adjust the layout of DeployImageDialog.
--- bitbake/lib/bb/ui/crumbs/hig.py | 43 +++++++++++++++++++++++++++++++++----- 1 files changed, 37 insertions(+), 6 deletions(-)
bitbake/lib/bb/ui/crumbs/hig.py +37 -6
@@ -749,21 +749,28 @@ class DeployImageDialog (CrumbsDialog): __dummy_usb__ = "--select a usb drive--" - def __init__(self, title, image_path, parent, flags, buttons=None): + 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)
@@ -771,11 +778,26 @@ class DeployImageDialog (CrumbsDialog): 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) + self.buf = gtk.TextBuffer() + self.buf.set_text(self.image_path) + tv.set_buffer(self.buf) scroll.add(tv) - self.vbox.pack_start(scroll, expand=True, fill=True) + table.attach(scroll, 0, 10, 0, 1) + + 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)
@@ -790,7 +812,7 @@ class DeployImageDialog (CrumbsDialog): 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_combo, expand=False, fill=False) self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2) self.progress_bar = HobProgressBar()
@@ -801,6 +823,12 @@ class DeployImageDialog (CrumbsDialog): 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()
@@ -816,6 +844,9 @@ class DeployImageDialog (CrumbsDialog): (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__:
Signature · 1 line
1.7.5.4
Re: [PATCH 5/6] hob2: update DeployImageDialog for seperated tool
Quoted 50 lines · Kang Kai
Part of [Yocto 2388]
Update class DeployImageDialog to get ready for a standalone deploy image tool. The standalone tool can be run directly without hob, and add a button to select image file. So adjust the layout of DeployImageDialog.
Signed-off-by Kang Kai <[email protected]>--- bitbake/lib/bb/ui/crumbs/hig.py | 43 +++++++++++++++++++++++++++++++++----- 1 files changed, 37 insertions(+), 6 deletions(-)bitbake/lib/bb/ui/crumbs/hig.py +8
-1@@ -749,21 +749,28 @@ class DeployImageDialog (CrumbsDialog): __dummy_usb__ = "--select a usb drive--" - def __init__(self, title, image_path, parent, flags, buttons=None): + 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)@@ -771,11 +778,26 @@ class DeployImageDialog (CrumbsDialog): tv.set_editable(False) tv.set_wrap_mode(gtk.WRAP_WORD) tv.set_cursor_visible(False)
bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 786
Quoted 10 lines
bitbake/lib/bb/ui/crumbs/hig.py +5
-4- buf = gtk.TextBuffer() - buf.set_text(self.image_path) - tv.set_buffer(buf) + self.buf = gtk.TextBuffer() + self.buf.set_text(self.image_path) + tv.set_buffer(self.buf) scroll.add(tv) - self.vbox.pack_start(scroll, expand=True, fill=True) + table.attach(scroll, 0, 10, 0, 1) +
The following block probably warrants a comment regarding why this is needed as it isn't obvious reading the code.
Quoted 49 lines
bitbake/lib/bb/ui/crumbs/hig.py +24
-1+ 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)@@ -790,7 +812,7 @@ class DeployImageDialog (CrumbsDialog): 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_combo, expand=False, fill=False) self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2) self.progress_bar = HobProgressBar()@@ -801,6 +823,12 @@ class DeployImageDialog (CrumbsDialog): 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()@@ -816,6 +844,9 @@ class DeployImageDialog (CrumbsDialog): (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__:
Signature · 3 lines
Darren Hart Intel Open Source Technology Center Yocto Project - Linux Kernel
PATCH 6/6 hob2: create a standalone deploy image tool
In reply to Kang Kai[Yocto 2388]
Create a deploy image tool using the existing dialog including DeployImageDialog and ImageSelectionDialog.
This tool writes bootable images to USB devices, and it can be run directly without hob.
--- bitbake/bin/image-writer | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 120 insertions(+), 0 deletions(-) create mode 100755 bitbake/bin/image-writer
bitbake/bin/image-writer new file +120 -0
@@ -0,0 +1,120 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 Wind River Systems, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import os +import sys +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname( \ + os.path.abspath(__file__))), 'lib')) +try: + import bb +except RuntimeError as exc: + sys.exit(str(exc)) + +import gtk +import optparse +import pygtk + +from bb.ui.crumbs.hig import DeployImageDialog, ImageSelectionDialog, CrumbsMessageDialog +from bb.ui.crumbs.hobwidget import HobAltButton, HobButton + +# I put all the fs bitbake supported here. Need more test. +DEPLOYABLE_IMAGE_TYPES = ["jffs2", "cramfs", "ext2", "ext3", "btrfs", "squashfs", "ubi", "vmdk"] +Title = "USB Image Maker" + +class DeployWindow(gtk.Window): + def __init__(self, image_path=''): + super(DeployWindow, self).__init__() + + if len(image_path) > 0: + valid = True + if not os.path.exists(image_path): + valid = False + lbl = "<b>Invalid image file path: %s.</b>\nPress <b>Select Image</b> button to select an image." % image_path + else: + image_path = os.path.abspath(image_path) + extend_name = os.path.splitext(image_path)[1][1:] + if extend_name not in DEPLOYABLE_IMAGE_TYPES: + valid = False + lbl = "<b>Undeployable imge type: %s</b>\nPress <b>Select Image</b> button to select an image." % extend_name + + if not valid: + image_path = '' + 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() + + self.deploy_dialog = DeployImageDialog(Title, image_path, self, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT + | gtk.DIALOG_NO_SEPARATOR, None, standalone=True) + close_button = self.deploy_dialog.add_button("Close", gtk.RESPONSE_NO) + HobAltButton.style_button(close_button) + close_button.connect('clicked', gtk.main_quit) + + make_button = self.deploy_dialog.add_button("Make USB image", gtk.RESPONSE_YES) + HobAltButton.style_button(make_button) + + self.deploy_dialog.connect('select_image_clicked', self.select_image_clicked_cb) + self.deploy_dialog.connect('destroy', gtk.main_quit) + response = self.deploy_dialog.show() + + def select_image_clicked_cb(self, dialog): + cwd = os.getcwd() + dialog = ImageSelectionDialog(cwd, DEPLOYABLE_IMAGE_TYPES, Title, 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) + HobAltButton.style_button(button) + response = dialog.run() + + if response == gtk.RESPONSE_YES: + if not dialog.image_names: + lbl = "<b>No selections made</b>\nClicked the radio button to select a image." + 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 + + # get the full path of image + image_path = os.path.join(dialog.image_folder, dialog.image_names[0]) + self.deploy_dialog.set_image_text_buffer(image_path) + self.deploy_dialog.set_image_path(image_path) + + dialog.destroy() + +def main(): + parser = optparse.OptionParser( + usage = """%prog [-h] [image_file] + +%prog writes bootable images to USB devices. You can +provide the image file on the command line or select it using the GUI.""") + + options, args = parser.parse_args(sys.argv) + image_file = args[1] if len(args) > 1 else '' + dw = DeployWindow(image_file) + +if __name__ == '__main__': + try: + main() + gtk.main() + except Exception: + import traceback + traceback.print_exc(3)
Signature · 1 line
1.7.5.4
Re: [PATCH 6/6] hob2: create a standalone deploy image tool
Quoted 46 lines · Kang Kai
[Yocto 2388]
Create a deploy image tool using the existing dialog including DeployImageDialog and ImageSelectionDialog.
This tool writes bootable images to USB devices, and it can be run directly without hob.
Signed-off-by Kang Kai <[email protected]>--- bitbake/bin/image-writer | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 120 insertions(+), 0 deletions(-) create mode 100755 bitbake/bin/image-writerbitbake/bin/image-writer new file +26
-0@@ -0,0 +1,120 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 Wind River Systems, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import os +import sys +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname( \ + os.path.abspath(__file__))), 'lib')) +try: + import bb +except RuntimeError as exc: + sys.exit(str(exc)) +
bitbake/bin/image-writer line 36
Quoted 10 lines
bitbake/bin/image-writer new file +10
-0+import gtk +import optparse +import pygtk + +from bb.ui.crumbs.hig import DeployImageDialog, ImageSelectionDialog, CrumbsMessageDialog +from bb.ui.crumbs.hobwidget import HobAltButton, HobButton + +# I put all the fs bitbake supported here. Need more test. +DEPLOYABLE_IMAGE_TYPES = ["jffs2", "cramfs", "ext2", "ext3", "btrfs", "squashfs", "ubi", "vmdk"] +Title = "USB Image Maker"
Writer is probably a more apt name than Maker.
bitbake/bin/image-writer line 46
Quoted 10 lines
bitbake/bin/image-writer new file +10
-0+ +class DeployWindow(gtk.Window): + def __init__(self, image_path=''): + super(DeployWindow, self).__init__() + + if len(image_path) > 0: + valid = True + if not os.path.exists(image_path): + valid = False + lbl = "<b>Invalid image file path: %s.</b>\nPress <b>Select Image</b> button to select an image." % image_path
I commented on this text in the last review. If you are going to leave the word "button" in there, then you need an article prior to "Select Image" (the). I would recommend using "Select Image" as a proper noun, and drop the term "button".
bitbake/bin/image-writer line 52
Quoted 6 lines
bitbake/bin/image-writer new file +6
-0+ else: + image_path = os.path.abspath(image_path) + extend_name = os.path.splitext(image_path)[1][1:] + if extend_name not in DEPLOYABLE_IMAGE_TYPES: + valid = False + lbl = "<b>Undeployable imge type: %s</b>\nPress <b>Select Image</b> button to select an image." % extend_name
Same here.
Quoted 7 lines
bitbake/bin/image-writer new file +7
-0+ + if not valid: + image_path = '' + 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()
bitbake/bin/image-writer line 69
Quoted 10 lines
bitbake/bin/image-writer new file +10
-0+ crumbs_dialog.destroy() + + self.deploy_dialog = DeployImageDialog(Title, image_path, self, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT + | gtk.DIALOG_NO_SEPARATOR, None, standalone=True) + close_button = self.deploy_dialog.add_button("Close", gtk.RESPONSE_NO) + HobAltButton.style_button(close_button) + close_button.connect('clicked', gtk.main_quit) + + make_button = self.deploy_dialog.add_button("Make USB image", gtk.RESPONSE_YES)
"Write" is probably more descriptive than "Make"
Quoted 51 lines
bitbake/bin/image-writer new file +51
-0+ HobAltButton.style_button(make_button) + + self.deploy_dialog.connect('select_image_clicked', self.select_image_clicked_cb) + self.deploy_dialog.connect('destroy', gtk.main_quit) + response = self.deploy_dialog.show() + + def select_image_clicked_cb(self, dialog): + cwd = os.getcwd() + dialog = ImageSelectionDialog(cwd, DEPLOYABLE_IMAGE_TYPES, Title, 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) + HobAltButton.style_button(button) + response = dialog.run() + + if response == gtk.RESPONSE_YES: + if not dialog.image_names: + lbl = "<b>No selections made</b>\nClicked the radio button to select a image." + 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 + + # get the full path of image + image_path = os.path.join(dialog.image_folder, dialog.image_names[0]) + self.deploy_dialog.set_image_text_buffer(image_path) + self.deploy_dialog.set_image_path(image_path) + + dialog.destroy() + +def main(): + parser = optparse.OptionParser( + usage = """%prog [-h] [image_file] + +%prog writes bootable images to USB devices. You can +provide the image file on the command line or select it using the GUI.""") + + options, args = parser.parse_args(sys.argv) + image_file = args[1] if len(args) > 1 else '' + dw = DeployWindow(image_file) + +if __name__ == '__main__': + try: + main() + gtk.main() + except Exception: + import traceback + traceback.print_exc(3)
Signature · 3 lines
Darren Hart Intel Open Source Technology Center Yocto Project - Linux Kernel
Richard Purdie
AppliedQuoted 25 lines · Kang Kai
Hi Darren,
Thanks for your detailed reivew.
V2 update:
1. break up the commit abouthig.py
2. some text tweak
3. remove the gtk version check
4. rename the standalone toolV1:
These 2 patches try to add a standalone deploy image tool using current codes. It should be launched by run the absolute path to bitbake/bin/bitbake-deployimage, I'll add a shell script to wrap it under script directory.Regards,
Kai
The following changes since commitde4cdfd6bc1280ac7ac0559b87734d26294ef773:
documentation/kernel-manual/kernel-how-to.xml: Updated to kernel 3.4 (2012-05-31 21:16:55 +0100)are available in the git repository at:
git://git.pokylinux.org/poky-contribkangkai/distro
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/distro
Quoted 7 lines
Kang Kai (6):
ui/crumbs/utils.py: import module bbui/crumbs/hig.py: fix run time errorui/crumbs/hig.py: remove extra spacesui/crumbs/hig.py: check deploy process return value
hob2: update DeployImageDialog for seperated tool
hob2: create a standalone deploy image tool
Merged to master, thanks.
Richard
Quoted 34 lines · Richard Purdie
Quoted 25 lines · Kang Kai
Hi Darren,
Thanks for your detailed reivew.
V2 update:
1. break up the commit abouthig.py
2. some text tweak
3. remove the gtk version check
4. rename the standalone toolV1:
These 2 patches try to add a standalone deploy image tool using current codes. It should be launched by run the absolute path to bitbake/bin/bitbake-deployimage, I'll add a shell script to wrap it under script directory.Regards,
Kai
The following changes since commitde4cdfd6bc1280ac7ac0559b87734d26294ef773:
documentation/kernel-manual/kernel-how-to.xml: Updated to kernel 3.4 (2012-05-31 21:16:55 +0100)are available in the git repository at:
git://git.pokylinux.org/poky-contribkangkai/distro
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/distroQuoted 7 lines
Kang Kai (6):
ui/crumbs/utils.py: import module bbui/crumbs/hig.py: fix run time errorui/crumbs/hig.py: remove extra spacesui/crumbs/hig.py: check deploy process return value
hob2: update DeployImageDialog for seperated tool
hob2: create a standalone deploy image tool
Quoted 1 line
Merged to master, thanks.
This happened a bit more quickly than I could get to reviewing V2 for the inclusion of my feedback.
I've gone ahead and reviewed the patchset again. The breakout looks spot on, thanks Kang. There are various other minor issues, mostly with the strings. Please have a look and consider submitting a follow-on patch series.
Thanks,
Signature · 3 lines
Darren Hart Intel Open Source Technology Center Yocto Project - Linux Kernel
Quoted 28 lines · Darren Hart
Quoted 26 lines · Richard Purdie
Quoted 25 lines · Kang Kai
Hi Darren,
Thanks for your detailed reivew.
V2 update:
1. break up the commit abouthig.py
2. some text tweak
3. remove the gtk version check
4. rename the standalone toolV1:
These 2 patches try to add a standalone deploy image tool using current codes. It should be launched by run the absolute path to bitbake/bin/bitbake-deployimage, I'll add a shell script to wrap it under script directory.Regards,
Kai
The following changes since commitde4cdfd6bc1280ac7ac0559b87734d26294ef773:documentation/kernel-manual/kernel-how-to.xml: Updated to kernel 3.4 (2012-05-31 21:16:55 +0100)are available in the git repository at:
git://git.pokylinux.org/poky-contribkangkai/distro
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/distro
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Kang Kai (6):
ui/crumbs/utils.py: import module bbui/crumbs/hig.py: fix run time errorui/crumbs/hig.py: remove extra spacesui/crumbs/hig.py: check deploy process return value
hob2: update DeployImageDialog for seperated tool
hob2: create a standalone deploy image toolMerged to master, thanks.
Hi Darren,
Quoted 7 lines
This happened a bit more quickly than I could get to reviewing V2 for the inclusion of my feedback.
I've gone ahead and reviewed the patchset again. The breakout looks spot on, thanks Kang. There are various other minor issues, mostly with the strings. Please have a look and consider submitting a follow-on patch series.
Sorry for late response because I had sick leave for last 2 days. I will send patch to amend the problems according to your comments.
Thanks,
Kai
Quoted 2 lines
Thanks,