* [PATCH 0/2] hob2: add a standalone deploy image tool
@ 2012-06-05 3:37 Kang Kai
2012-06-05 3:37 ` [PATCH 1/2] hob2: update DeployImageDialog for seperated tool Kang Kai
2012-06-05 3:37 ` [PATCH 2/2] hob2: create a standalone deploy image tool Kang Kai
0 siblings, 2 replies; 14+ messages in thread
From: Kang Kai @ 2012-06-05 3:37 UTC (permalink / raw)
To: dvhart; +Cc: bitbake-devel, zhenfeng.zhao
Hi,
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 (2):
hob2: update DeployImageDialog for seperated tool
hob2: create a standalone deploy image tool
bitbake/bin/bitbake-deployimage | 135 +++++++++++++++++++++++++++++++++++++
bitbake/lib/bb/ui/crumbs/hig.py | 82 +++++++++++++++++++----
bitbake/lib/bb/ui/crumbs/utils.py | 1 +
3 files changed, 204 insertions(+), 14 deletions(-)
create mode 100755 bitbake/bin/bitbake-deployimage
--
1.7.5.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/2] hob2: update DeployImageDialog for seperated tool
2012-06-05 3:37 [PATCH 0/2] hob2: add a standalone deploy image tool Kang Kai
@ 2012-06-05 3:37 ` Kang Kai
2012-06-05 17:38 ` Darren Hart
2012-06-05 3:37 ` [PATCH 2/2] hob2: create a standalone deploy image tool Kang Kai
1 sibling, 1 reply; 14+ messages in thread
From: Kang Kai @ 2012-06-05 3:37 UTC (permalink / raw)
To: dvhart; +Cc: bitbake-devel, zhenfeng.zhao
Part of [Yocto 2388]
Update class DeployImageDialog that could be used by a standalone
deploy image tool.
Update the method to get all usb device to avoid runtime error, and
get the deploy image process exit status then give user a information
dialog.
Remove some extra spaces at same time.
Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
bitbake/lib/bb/ui/crumbs/hig.py | 82 ++++++++++++++++++++++++++++++++-------
1 files changed, 68 insertions(+), 14 deletions(-)
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
index 7c9e73f..7d8daad 100644
--- a/bitbake/lib/bb/ui/crumbs/hig.py
+++ b/bitbake/lib/bb/ui/crumbs/hig.py
@@ -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
@@ -63,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)
@@ -748,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, singleton=False):
super(DeployImageDialog, self).__init__(title, parent, flags, buttons)
self.image_path = image_path
+ self.singleton = singleton
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)
@@ -770,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.singleton:
+ 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)
@@ -789,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()
@@ -800,13 +823,19 @@ 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()
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 ]
@@ -815,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__:
@@ -826,12 +858,34 @@ 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()
+ 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 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)
@@ -1035,7 +1089,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)
@@ -1210,7 +1264,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)
@@ -1226,7 +1280,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):
--
1.7.5.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-05 3:37 [PATCH 0/2] hob2: add a standalone deploy image tool Kang Kai
2012-06-05 3:37 ` [PATCH 1/2] hob2: update DeployImageDialog for seperated tool Kang Kai
@ 2012-06-05 3:37 ` Kang Kai
2012-06-05 6:42 ` Wang, Shane
2012-06-05 17:55 ` Darren Hart
1 sibling, 2 replies; 14+ messages in thread
From: Kang Kai @ 2012-06-05 3:37 UTC (permalink / raw)
To: dvhart; +Cc: bitbake-devel, zhenfeng.zhao
[Yocto 2388]
Create a standalone deploy image tool using the existing dialog
including DeployImageDialog and ImageSelectionDialog.
Duplicate the gtk and pygtk versions check in the hob.py because this
will be run separately.
Update ui/crumbs/utils.py that it needs to 'import bb' when run this
tool.
Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
bitbake/bin/bitbake-deployimage | 135 +++++++++++++++++++++++++++++++++++++
bitbake/lib/bb/ui/crumbs/utils.py | 1 +
2 files changed, 136 insertions(+), 0 deletions(-)
create mode 100755 bitbake/bin/bitbake-deployimage
diff --git a/bitbake/bin/bitbake-deployimage b/bitbake/bin/bitbake-deployimage
new file mode 100755
index 0000000..8fdd21b
--- /dev/null
+++ b/bitbake/bin/bitbake-deployimage
@@ -0,0 +1,135 @@
+#!/usr/bin/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
+import optparse
+
+requirements = "FATAL: Gtk+ 2.20.0 or higher, PyGtk version 2.22.0 or higher and PyGobject are required to use Hob"
+try:
+ import gtk
+ import pygtk
+
+ pygtk.require('2.0') # to be certain we don't have gtk+ 1.x !?!
+ gtkver = gtk.gtk_version
+ pygtkver = gtk.pygtk_version
+ if gtkver < (2, 20, 0) or pygtkver < (2, 22, 0):
+ sys.exit("%s,\nYou have Gtk+ %s and PyGtk %s." % (requirements,
+ ".".join(map(str, gtkver)),
+ ".".join(map(str, pygtkver))))
+
+except ImportError as exc:
+ sys.exit("%s (%s)." % (requirements, str(exc)))
+
+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))
+
+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</b>\nYou could use <b>Select Image</b> button to select image"
+ 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</b>\nYou could use <b>Select Image</b> button to select image"
+
+ 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, singleton=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>\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
+
+ # 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]
+
+This deploy image tool try to deploy the bitbake images to USB devices.
+You could provides the image file from command line or select it use the
+GUI tool.""")
+
+ 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)
diff --git a/bitbake/lib/bb/ui/crumbs/utils.py b/bitbake/lib/bb/ui/crumbs/utils.py
index cd01a04..939864f 100644
--- a/bitbake/lib/bb/ui/crumbs/utils.py
+++ b/bitbake/lib/bb/ui/crumbs/utils.py
@@ -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")
--
1.7.5.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-05 3:37 ` [PATCH 2/2] hob2: create a standalone deploy image tool Kang Kai
@ 2012-06-05 6:42 ` Wang, Shane
2012-06-05 7:04 ` Kang Kai
2012-06-05 17:55 ` Darren Hart
1 sibling, 1 reply; 14+ messages in thread
From: Wang, Shane @ 2012-06-05 6:42 UTC (permalink / raw)
To: Kang Kai, dvhart@linux.intel.com
Cc: bitbake-devel@lists.openembedded.org, zhenfeng.zhao@windriver.com
> -----Original Message-----
> From: Kang Kai [mailto:kai.kang@windriver.com]
> Sent: Tuesday, June 05, 2012 11:37 AM
> To: dvhart@linux.intel.com
> Cc: Wang, Shane; zhenfeng.zhao@windriver.com;
> bitbake-devel@lists.openembedded.org
> Subject: [PATCH 2/2] hob2: create a standalone deploy image tool
>
> [Yocto 2388]
>
> Create a standalone deploy image tool using the existing dialog
> including DeployImageDialog and ImageSelectionDialog.
>
> Duplicate the gtk and pygtk versions check in the hob.py because this
> will be run separately.
>
> Update ui/crumbs/utils.py that it needs to 'import bb' when run this
> tool.
>
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
> bitbake/bin/bitbake-deployimage | 135
> +++++++++++++++++++++++++++++++++++++
> bitbake/lib/bb/ui/crumbs/utils.py | 1 +
> 2 files changed, 136 insertions(+), 0 deletions(-)
> create mode 100755 bitbake/bin/bitbake-deployimage
>
> diff --git a/bitbake/bin/bitbake-deployimage
> b/bitbake/bin/bitbake-deployimage
> new file mode 100755
> index 0000000..8fdd21b
> --- /dev/null
> +++ b/bitbake/bin/bitbake-deployimage
> @@ -0,0 +1,135 @@
> +#!/usr/bin/python
> +
> +
> +requirements = "FATAL: Gtk+ 2.20.0 or higher, PyGtk version 2.22.0 or higher
> and PyGobject are required to use Hob"
Kai, I don't like you have this kind of limitation for GTK and PyGTK.
Hob.py does have because we want special efforts on the visual components. For this simple app,
I don't want you to exclude a lot of users who only have lower versions.
> diff --git a/bitbake/lib/bb/ui/crumbs/utils.py
> b/bitbake/lib/bb/ui/crumbs/utils.py
> index cd01a04..939864f 100644
> --- a/bitbake/lib/bb/ui/crumbs/utils.py
> +++ b/bitbake/lib/bb/ui/crumbs/utils.py
> @@ -22,6 +22,7 @@
> # bitbake which will allow more flexibility.
>
> import os
> +import bb
Why is this needed? I don't see any change you made in utils.py.
Is that to say without this line, the functions in utils.py don't work?
>
> def which_terminal():
> term = bb.utils.which(os.environ["PATH"], "xterm")
> --
> 1.7.5.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-05 6:42 ` Wang, Shane
@ 2012-06-05 7:04 ` Kang Kai
2012-06-05 7:40 ` Wang, Shane
0 siblings, 1 reply; 14+ messages in thread
From: Kang Kai @ 2012-06-05 7:04 UTC (permalink / raw)
To: Wang, Shane
Cc: bitbake-devel@lists.openembedded.org, zhenfeng.zhao@windriver.com
On 2012年06月05日 14:42, Wang, Shane wrote:
>> -----Original Message-----
>> From: Kang Kai [mailto:kai.kang@windriver.com]
>> Sent: Tuesday, June 05, 2012 11:37 AM
>> To: dvhart@linux.intel.com
>> Cc: Wang, Shane; zhenfeng.zhao@windriver.com;
>> bitbake-devel@lists.openembedded.org
>> Subject: [PATCH 2/2] hob2: create a standalone deploy image tool
>>
>> [Yocto 2388]
>>
>> Create a standalone deploy image tool using the existing dialog
>> including DeployImageDialog and ImageSelectionDialog.
>>
>> Duplicate the gtk and pygtk versions check in the hob.py because this
>> will be run separately.
>>
>> Update ui/crumbs/utils.py that it needs to 'import bb' when run this
>> tool.
>>
>> Signed-off-by: Kang Kai<kai.kang@windriver.com>
>> ---
>> bitbake/bin/bitbake-deployimage | 135
>> +++++++++++++++++++++++++++++++++++++
>> bitbake/lib/bb/ui/crumbs/utils.py | 1 +
>> 2 files changed, 136 insertions(+), 0 deletions(-)
>> create mode 100755 bitbake/bin/bitbake-deployimage
>>
>> diff --git a/bitbake/bin/bitbake-deployimage
>> b/bitbake/bin/bitbake-deployimage
>> new file mode 100755
>> index 0000000..8fdd21b
>> --- /dev/null
>> +++ b/bitbake/bin/bitbake-deployimage
>> @@ -0,0 +1,135 @@
>> +#!/usr/bin/python
>> +
>> +
>> +requirements = "FATAL: Gtk+ 2.20.0 or higher, PyGtk version 2.22.0 or higher
>> and PyGobject are required to use Hob"
Hi Shane,
> Kai, I don't like you have this kind of limitation for GTK and PyGTK.
> Hob.py does have because we want special efforts on the visual components. For this simple app,
> I don't want you to exclude a lot of users who only have lower versions.
Fine, I'll remove the version check.
>
>
>
>> diff --git a/bitbake/lib/bb/ui/crumbs/utils.py
>> b/bitbake/lib/bb/ui/crumbs/utils.py
>> index cd01a04..939864f 100644
>> --- a/bitbake/lib/bb/ui/crumbs/utils.py
>> +++ b/bitbake/lib/bb/ui/crumbs/utils.py
>> @@ -22,6 +22,7 @@
>> # bitbake which will allow more flexibility.
>>
>> import os
>> +import bb
> Why is this needed? I don't see any change you made in utils.py.
> Is that to say without this line, the functions in utils.py don't work?
Without the import, it just complains that
NameError: global name 'bb' is not defined
Regards,
Kai
>
>> def which_terminal():
>> term = bb.utils.which(os.environ["PATH"], "xterm")
>> --
>> 1.7.5.4
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-05 7:04 ` Kang Kai
@ 2012-06-05 7:40 ` Wang, Shane
2012-06-05 8:15 ` Kang Kai
0 siblings, 1 reply; 14+ messages in thread
From: Wang, Shane @ 2012-06-05 7:40 UTC (permalink / raw)
To: Kang Kai
Cc: bitbake-devel@lists.openembedded.org, zhenfeng.zhao@windriver.com
Kang Kai wrote on 2012-06-05:
> On 2012年06月05日 14:42, Wang, Shane wrote:
>>> -----Original Message-----
>>> From: Kang Kai [mailto:kai.kang@windriver.com]
>>> Sent: Tuesday, June 05, 2012 11:37 AM
>>> To: dvhart@linux.intel.com
>>> Cc: Wang, Shane; zhenfeng.zhao@windriver.com;
>>> bitbake-devel@lists.openembedded.org
>>> Subject: [PATCH 2/2] hob2: create a standalone deploy image tool
>>>
>>> diff --git a/bitbake/lib/bb/ui/crumbs/utils.py
>>> b/bitbake/lib/bb/ui/crumbs/utils.py
>>> index cd01a04..939864f 100644
>>> --- a/bitbake/lib/bb/ui/crumbs/utils.py
>>> +++ b/bitbake/lib/bb/ui/crumbs/utils.py
>>> @@ -22,6 +22,7 @@
>>> # bitbake which will allow more flexibility.
>>>
>>> import os
>>> +import bb
>> Why is this needed? I don't see any change you made in utils.py.
>> Is that to say without this line, the functions in utils.py don't work?
>
> Without the import, it just complains that
>
> NameError: global name 'bb' is not defined
>
> Regards,
> Kai
OK, It seems Saul didn't test it when he created utils.py;-)
--
Shane
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-05 7:40 ` Wang, Shane
@ 2012-06-05 8:15 ` Kang Kai
2012-06-05 17:24 ` Darren Hart
0 siblings, 1 reply; 14+ messages in thread
From: Kang Kai @ 2012-06-05 8:15 UTC (permalink / raw)
To: Wang, Shane
Cc: bitbake-devel@lists.openembedded.org, zhenfeng.zhao@windriver.com
On 2012年06月05日 15:40, Wang, Shane wrote:
> Kang Kai wrote on 2012-06-05:
>
>> On 2012年06月05日 14:42, Wang, Shane wrote:
>>>> -----Original Message-----
>>>> From: Kang Kai [mailto:kai.kang@windriver.com]
>>>> Sent: Tuesday, June 05, 2012 11:37 AM
>>>> To: dvhart@linux.intel.com
>>>> Cc: Wang, Shane; zhenfeng.zhao@windriver.com;
>>>> bitbake-devel@lists.openembedded.org
>>>> Subject: [PATCH 2/2] hob2: create a standalone deploy image tool
>>>>
>>>> diff --git a/bitbake/lib/bb/ui/crumbs/utils.py
>>>> b/bitbake/lib/bb/ui/crumbs/utils.py
>>>> index cd01a04..939864f 100644
>>>> --- a/bitbake/lib/bb/ui/crumbs/utils.py
>>>> +++ b/bitbake/lib/bb/ui/crumbs/utils.py
>>>> @@ -22,6 +22,7 @@
>>>> # bitbake which will allow more flexibility.
>>>>
>>>> import os
>>>> +import bb
>>> Why is this needed? I don't see any change you made in utils.py.
>>> Is that to say without this line, the functions in utils.py don't work?
>> Without the import, it just complains that
>>
>> NameError: global name 'bb' is not defined
>>
>> Regards,
>> Kai
> OK, It seems Saul didn't test it when he created utils.py;-)
I am not quit sure because it is fine when call the deploy image in the
hob. little weird.
Regards,
Kai
>
> --
> Shane
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-05 8:15 ` Kang Kai
@ 2012-06-05 17:24 ` Darren Hart
2012-06-06 3:29 ` Kang Kai
0 siblings, 1 reply; 14+ messages in thread
From: Darren Hart @ 2012-06-05 17:24 UTC (permalink / raw)
To: Kang Kai
Cc: bitbake-devel@lists.openembedded.org, zhenfeng.zhao@windriver.com
On 06/05/2012 01:15 AM, Kang Kai wrote:
> On 2012年06月05日 15:40, Wang, Shane wrote:
>> Kang Kai wrote on 2012-06-05:
>>
>>> On 2012年06月05日 14:42, Wang, Shane wrote:
>>>>> -----Original Message-----
>>>>> From: Kang Kai [mailto:kai.kang@windriver.com]
>>>>> Sent: Tuesday, June 05, 2012 11:37 AM
>>>>> To: dvhart@linux.intel.com
>>>>> Cc: Wang, Shane; zhenfeng.zhao@windriver.com;
>>>>> bitbake-devel@lists.openembedded.org
>>>>> Subject: [PATCH 2/2] hob2: create a standalone deploy image tool
>>>>>
>>>>> diff --git a/bitbake/lib/bb/ui/crumbs/utils.py
>>>>> b/bitbake/lib/bb/ui/crumbs/utils.py
>>>>> index cd01a04..939864f 100644
>>>>> --- a/bitbake/lib/bb/ui/crumbs/utils.py
>>>>> +++ b/bitbake/lib/bb/ui/crumbs/utils.py
>>>>> @@ -22,6 +22,7 @@
>>>>> # bitbake which will allow more flexibility.
>>>>>
>>>>> import os
>>>>> +import bb
>>>> Why is this needed? I don't see any change you made in utils.py.
>>>> Is that to say without this line, the functions in utils.py don't work?
>>> Without the import, it just complains that
>>>
>>> NameError: global name 'bb' is not defined
>>>
>>> Regards,
>>> Kai
>> OK, It seems Saul didn't test it when he created utils.py;-)
>
> I am not quit sure because it is fine when call the deploy image in the
> hob. little weird.
>
Probably because another file in the import list includes bb.
However, this change is not specific to the image tool and should be
broken out as a separate patch. utils.py makes calls to bb.utils.which()
on the third source line, so bb should certainly be imported in utils.py.
--
Darren
> Regards,
> Kai
>
>>
>> --
>> Shane
>
--
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] hob2: update DeployImageDialog for seperated tool
2012-06-05 3:37 ` [PATCH 1/2] hob2: update DeployImageDialog for seperated tool Kang Kai
@ 2012-06-05 17:38 ` Darren Hart
2012-06-06 2:33 ` Kang Kai
0 siblings, 1 reply; 14+ messages in thread
From: Darren Hart @ 2012-06-05 17:38 UTC (permalink / raw)
To: Kang Kai; +Cc: bitbake-devel, zhenfeng.zhao
On 06/04/2012 08:37 PM, Kang Kai wrote:
> Part of [Yocto 2388]
>
> Update class DeployImageDialog that could be used by a standalone
> deploy image tool.
>
> Update the method to get all usb device to avoid runtime error, and
> get the deploy image process exit status then give user a information
> dialog.
These are functionally different tasks that should probably broken up
into a couple patches. This allows us to revert one while maintaining
the other should a problem arise. It also makes reviewing the code easier.
>
> Remove some extra spaces at same time.
>
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
> bitbake/lib/bb/ui/crumbs/hig.py | 82 ++++++++++++++++++++++++++++++++-------
> 1 files changed, 68 insertions(+), 14 deletions(-)
>
> diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
> index 7c9e73f..7d8daad 100644
> --- a/bitbake/lib/bb/ui/crumbs/hig.py
> +++ b/bitbake/lib/bb/ui/crumbs/hig.py
> @@ -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
> @@ -63,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)
> @@ -748,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, singleton=False):
> super(DeployImageDialog, self).__init__(title, parent, flags, buttons)
>
> self.image_path = image_path
> + self.singleton = singleton
>
> 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)
> +
It isn't obvious to me why things like setting the size request and
creating a new table are required to make this stand alone. Do these
changes fit under the "Update class DeployImageDialog that could be used
by a standalone deploy image tool." ? If so, fine. If not, they might be
better done in a separate patch.
> scroll = gtk.ScrolledWindow()
> scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
> scroll.set_shadow_type(gtk.SHADOW_IN)
> @@ -770,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.singleton:
> + 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)
What does the self.singleton indicate? How is it related to running
stand-alone or within Hob?
> self.usb_desc = gtk.Label()
> self.usb_desc.set_alignment(0.0, 0.5)
> @@ -789,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)
This would appear to be a superfluous layout change unrelated to the
patch topic...
> self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2)
>
> self.progress_bar = HobProgressBar()
> @@ -800,13 +823,19 @@ 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()
>
> 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*')
Secondary to the goal of the patch, but why are we restricting ourselves
to sub drives? Why not read /proc/partitions and omit a configurable
blacklist of devices (like /dev/sda for example). Again, secondary to
this patch series.
> if not re.search(r'part\d+', u) ]
> return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ]
>
> @@ -815,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__:
> @@ -826,12 +858,34 @@ 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()
> + 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 image to deploy"
"<b>No selection made.</b>\nPlease select an image."
Is <br> appropriate here instead of \n?
> + else:
> + lbl = "<b>No selection made</b>\nYou have not selected USB device"
"<b>No selection made.</b>\nPlease select a device."
Again, why are we limiting devices to USB devices?
> + 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)
> @@ -1035,7 +1089,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)
> @@ -1210,7 +1264,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)
>
> @@ -1226,7 +1280,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):
--
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-05 3:37 ` [PATCH 2/2] hob2: create a standalone deploy image tool Kang Kai
2012-06-05 6:42 ` Wang, Shane
@ 2012-06-05 17:55 ` Darren Hart
1 sibling, 0 replies; 14+ messages in thread
From: Darren Hart @ 2012-06-05 17:55 UTC (permalink / raw)
To: Kang Kai; +Cc: bitbake-devel, zhenfeng.zhao
On 06/04/2012 08:37 PM, Kang Kai wrote:
> [Yocto 2388]
>
> Create a standalone deploy image tool using the existing dialog
> including DeployImageDialog and ImageSelectionDialog.
>
> Duplicate the gtk and pygtk versions check in the hob.py because this
> will be run separately.
>
> Update ui/crumbs/utils.py that it needs to 'import bb' when run this
> tool.
Should be a separate patch as it's independent of the image writer.
>
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
> bitbake/bin/bitbake-deployimage | 135 +++++++++++++++++++++++++++++++++++++
> bitbake/lib/bb/ui/crumbs/utils.py | 1 +
> 2 files changed, 136 insertions(+), 0 deletions(-)
> create mode 100755 bitbake/bin/bitbake-deployimage
>
> diff --git a/bitbake/bin/bitbake-deployimage b/bitbake/bin/bitbake-deployimage
> new file mode 100755
> index 0000000..8fdd21b
> --- /dev/null
> +++ b/bitbake/bin/bitbake-deployimage
A shorter name might be appropriate. Since this really doesn't involve
bitbake, maye we can drop that from the name? I would also suggest
avoiding the term "deploy" as it has a very specific meaning for
bitbake. Consider:
write-image
gddimage
hob-image
hob-dd
I don't love any of these, just thinking out loud.
> @@ -0,0 +1,135 @@
> +#!/usr/bin/python
This should be:
#!/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
> +import optparse
> +
> +requirements = "FATAL: Gtk+ 2.20.0 or higher, PyGtk version 2.22.0 or higher and PyGobject are required to use Hob"
But this isn't Hob, right? What is required to run just this script? I
think the requirements check is a good idea, but let's not unnecessarily
fail to run with overly strict requirement.s
> +try:
> + import gtk
> + import pygtk
> +
> + pygtk.require('2.0') # to be certain we don't have gtk+ 1.x !?!
> + gtkver = gtk.gtk_version
> + pygtkver = gtk.pygtk_version
> + if gtkver < (2, 20, 0) or pygtkver < (2, 22, 0):
> + sys.exit("%s,\nYou have Gtk+ %s and PyGtk %s." % (requirements,
> + ".".join(map(str, gtkver)),
> + ".".join(map(str, pygtkver))))
> +
> +except ImportError as exc:
> + sys.exit("%s (%s)." % (requirements, str(exc)))
> +
> +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))
> +
> +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"
s/Usb/USB/
Probably shouldn't be USB only in the future.
> +
> +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</b>\nYou could use <b>Select Image</b> button to select image"
Missing punctuation and articles:
"<b>Invalid image file path.</b>\nYou can use the <b>Select Image</b>
button to select an image."
Or
"<b>Invalid image file path: %s.</b>\nPress <b>Select Image</b> 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</b>\nYou could use <b>Select Image</b> button to select image"
Typo, missing articles and punctuation. Consider:
"<b>Undeployable image type: %s</b>\nPress <b>Select Image</b> 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, singleton=True)
Are you creating a proper singleton, or is this just used to indicate
"stand alone" ? Just curious as singleton's are quite difficult to do
properly in Python.
> + 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>\nYou have not made any selections"
This string is a bit redundant. The other strings in the app give
instructions to resolve the failure, should this as well?
> + 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]
> +
> +This deploy image tool try to deploy the bitbake images to USB devices.
> +You could provides the image file from command line or select it use the
> +GUI tool.""")
bitbake-deployimage 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)
> diff --git a/bitbake/lib/bb/ui/crumbs/utils.py b/bitbake/lib/bb/ui/crumbs/utils.py
> index cd01a04..939864f 100644
> --- a/bitbake/lib/bb/ui/crumbs/utils.py
> +++ b/bitbake/lib/bb/ui/crumbs/utils.py
> @@ -22,6 +22,7 @@
> # bitbake which will allow more flexibility.
>
> import os
> +import bb
separate patch.
>
> def which_terminal():
> term = bb.utils.which(os.environ["PATH"], "xterm")
--
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] hob2: update DeployImageDialog for seperated tool
2012-06-05 17:38 ` Darren Hart
@ 2012-06-06 2:33 ` Kang Kai
2012-06-06 3:01 ` Kang Kai
0 siblings, 1 reply; 14+ messages in thread
From: Kang Kai @ 2012-06-06 2:33 UTC (permalink / raw)
To: Darren Hart; +Cc: bitbake-devel, zhenfeng.zhao
On 2012年06月06日 01:38, Darren Hart wrote:
>
> On 06/04/2012 08:37 PM, Kang Kai wrote:
>> Part of [Yocto 2388]
>>
>> Update class DeployImageDialog that could be used by a standalone
>> deploy image tool.
>>
>> Update the method to get all usb device to avoid runtime error, and
>> get the deploy image process exit status then give user a information
>> dialog.
Hi Darren,
Thanks a lot for your detail comments.
One thing I want to address that the difference between standaonle
widget and called by hob is that the standalone widget add a image
selection button.
Maybe I use the wrong word "singleton" but that why I update the deploy
image dialog layout.
> These are functionally different tasks that should probably broken up
> into a couple patches. This allows us to revert one while maintaining
> the other should a problem arise. It also makes reviewing the code easier.
Ok, I'll break up it.
>
>> Remove some extra spaces at same time.
>>
>> Signed-off-by: Kang Kai<kai.kang@windriver.com>
>> ---
>> bitbake/lib/bb/ui/crumbs/hig.py | 82 ++++++++++++++++++++++++++++++++-------
>> 1 files changed, 68 insertions(+), 14 deletions(-)
>>
>> diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
>> index 7c9e73f..7d8daad 100644
>> --- a/bitbake/lib/bb/ui/crumbs/hig.py
>> +++ b/bitbake/lib/bb/ui/crumbs/hig.py
>> @@ -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
>> @@ -63,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)
>> @@ -748,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, singleton=False):
>> super(DeployImageDialog, self).__init__(title, parent, flags, buttons)
>>
>> self.image_path = image_path
>> + self.singleton = singleton
>>
>> 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)
>> +
>
> It isn't obvious to me why things like setting the size request and
> creating a new table are required to make this stand alone. Do these
> changes fit under the "Update class DeployImageDialog that could be used
> by a standalone deploy image tool." ? If so, fine. If not, they might be
> better done in a separate patch.
Without set the size request, the scroll bar doesn't show the text when
the deploy dialog shows.
It is ok to a separate patch.
>
>
>> scroll = gtk.ScrolledWindow()
>> scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
>> scroll.set_shadow_type(gtk.SHADOW_IN)
>> @@ -770,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.singleton:
>> + 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)
> What does the self.singleton indicate? How is it related to running
> stand-alone or within Hob?
As I mentioned above, I just add a image selection button when the tool
is run separately. It is convenience So I need to adjust the layout.
>
>> self.usb_desc = gtk.Label()
>> self.usb_desc.set_alignment(0.0, 0.5)
>> @@ -789,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)
> This would appear to be a superfluous layout change unrelated to the
> patch topic...
>
>> self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2)
>>
>> self.progress_bar = HobProgressBar()
>> @@ -800,13 +823,19 @@ 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()
>>
>> 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*')
> Secondary to the goal of the patch, but why are we restricting ourselves
> to sub drives? Why not read /proc/partitions and omit a configurable
> blacklist of devices (like /dev/sda for example). Again, secondary to
> this patch series.
This update just to fix runtime error after commit
094742bed2fc01d55f572da946fcfa7a48521401 when there is no USB device
then the program crashes.
If we want to deploy to other device, I'll update it.
>
>> if not re.search(r'part\d+', u) ]
>> return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ]
>>
>> @@ -815,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__:
>> @@ -826,12 +858,34 @@ 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()
>> + 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 image to deploy"
> "<b>No selection made.</b>\nPlease select an image."
>
> Is<br> appropriate here instead of \n?
Ok, thanks.
>
>> + else:
>> + lbl = "<b>No selection made</b>\nYou have not selected USB device"
> "<b>No selection made.</b>\nPlease select a device."
>
> Again, why are we limiting devices to USB devices?
Fine, if need I would update this part.
Regards,
Kai
>
>> + 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)
>> @@ -1035,7 +1089,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)
>> @@ -1210,7 +1264,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)
>>
>> @@ -1226,7 +1280,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):
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] hob2: update DeployImageDialog for seperated tool
2012-06-06 2:33 ` Kang Kai
@ 2012-06-06 3:01 ` Kang Kai
0 siblings, 0 replies; 14+ messages in thread
From: Kang Kai @ 2012-06-06 3:01 UTC (permalink / raw)
To: bitbake-devel
On 2012年06月06日 10:33, Kang Kai wrote:
> On 2012年06月06日 01:38, Darren Hart wrote:
>>
>> On 06/04/2012 08:37 PM, Kang Kai wrote:
>>> Part of [Yocto 2388]
>>>
>>> Update class DeployImageDialog that could be used by a standalone
>>> deploy image tool.
>>>
>>> Update the method to get all usb device to avoid runtime error, and
>>> get the deploy image process exit status then give user a information
>>> dialog.
>
> Hi Darren,
>
> Thanks a lot for your detail comments.
>
> One thing I want to address that the difference between standaonle
> widget and called by hob is that the standalone widget add a image
> selection button.
> Maybe I use the wrong word "singleton" but that why I update the
> deploy image dialog layout.
>
>> These are functionally different tasks that should probably broken up
>> into a couple patches. This allows us to revert one while maintaining
>> the other should a problem arise. It also makes reviewing the code
>> easier.
> Ok, I'll break up it.
>
>>
>>> Remove some extra spaces at same time.
>>>
>>> Signed-off-by: Kang Kai<kai.kang@windriver.com>
>>> ---
>>> bitbake/lib/bb/ui/crumbs/hig.py | 82
>>> ++++++++++++++++++++++++++++++++-------
>>> 1 files changed, 68 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/bitbake/lib/bb/ui/crumbs/hig.py
>>> b/bitbake/lib/bb/ui/crumbs/hig.py
>>> index 7c9e73f..7d8daad 100644
>>> --- a/bitbake/lib/bb/ui/crumbs/hig.py
>>> +++ b/bitbake/lib/bb/ui/crumbs/hig.py
>>> @@ -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
>>> @@ -63,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)
>>> @@ -748,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, singleton=False):
>>> super(DeployImageDialog, self).__init__(title, parent,
>>> flags, buttons)
>>>
>>> self.image_path = image_path
>>> + self.singleton = singleton
>>>
>>> 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)
>>> +
>>
>> It isn't obvious to me why things like setting the size request and
>> creating a new table are required to make this stand alone. Do these
>> changes fit under the "Update class DeployImageDialog that could be used
>> by a standalone deploy image tool." ? If so, fine. If not, they might be
>> better done in a separate patch.
>
> Without set the size request, the scroll bar doesn't show the text
> when the deploy dialog shows.
> It is ok to a separate patch.
>
>>
>>
>>> scroll = gtk.ScrolledWindow()
>>> scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
>>> scroll.set_shadow_type(gtk.SHADOW_IN)
>>> @@ -770,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.singleton:
>>> + 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)
>> What does the self.singleton indicate? How is it related to running
>> stand-alone or within Hob?
>
> As I mentioned above, I just add a image selection button when the
> tool is run separately. It is convenience So I need to adjust the layout.
>
>
>>
>>> self.usb_desc = gtk.Label()
>>> self.usb_desc.set_alignment(0.0, 0.5)
>>> @@ -789,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)
>> This would appear to be a superfluous layout change unrelated to the
>> patch topic...
>>
>>> self.vbox.pack_start(self.usb_desc, expand=False,
>>> fill=False, padding=2)
>>>
>>> self.progress_bar = HobProgressBar()
>>> @@ -800,13 +823,19 @@ 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()
>>>
>>> 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*')
>> Secondary to the goal of the patch, but why are we restricting ourselves
>> to sub drives? Why not read /proc/partitions and omit a configurable
>> blacklist of devices (like /dev/sda for example). Again, secondary to
>> this patch series.
>
> This update just to fix runtime error after commit
> 094742bed2fc01d55f572da946fcfa7a48521401 when there is no USB device
> then the program crashes.
> If we want to deploy to other device, I'll update it.
>
>>
>>> if not re.search(r'part\d+', u) ]
>>> return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ]
>>>
>>> @@ -815,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__:
>>> @@ -826,12 +858,34 @@ 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()
>>> + 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 image to deploy"
>> "<b>No selection made.</b>\nPlease select an image."
>>
>> Is<br> appropriate here instead of \n?
>
> Ok, thanks.
I am afraid the <br> is not supported here. It obeys pango markup
language and <br> is not supported.
Regards,
Kai
>
>>
>>> + else:
>>> + lbl = "<b>No selection made</b>\nYou have not
>>> selected USB device"
>> "<b>No selection made.</b>\nPlease select a device."
>>
>> Again, why are we limiting devices to USB devices?
> Fine, if need I would update this part.
>
> Regards,
> Kai
>>
>>> + 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)
>>> @@ -1035,7 +1089,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)
>>> @@ -1210,7 +1264,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)
>>>
>>> @@ -1226,7 +1280,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):
>
>
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/bitbake-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-05 17:24 ` Darren Hart
@ 2012-06-06 3:29 ` Kang Kai
2012-06-06 5:01 ` Wang, Shane
0 siblings, 1 reply; 14+ messages in thread
From: Kang Kai @ 2012-06-06 3:29 UTC (permalink / raw)
To: Darren Hart
Cc: bitbake-devel@lists.openembedded.org, zhenfeng.zhao@windriver.com
On 2012年06月06日 01:24, Darren Hart wrote:
>
> On 06/05/2012 01:15 AM, Kang Kai wrote:
>> On 2012年06月05日 15:40, Wang, Shane wrote:
>>> Kang Kai wrote on 2012-06-05:
>>>
>>>> On 2012年06月05日 14:42, Wang, Shane wrote:
>>>>>> -----Original Message-----
>>>>>> From: Kang Kai [mailto:kai.kang@windriver.com]
>>>>>> Sent: Tuesday, June 05, 2012 11:37 AM
>>>>>> To: dvhart@linux.intel.com
>>>>>> Cc: Wang, Shane; zhenfeng.zhao@windriver.com;
>>>>>> bitbake-devel@lists.openembedded.org
>>>>>> Subject: [PATCH 2/2] hob2: create a standalone deploy image tool
>>>>>>
>>>>>> diff --git a/bitbake/lib/bb/ui/crumbs/utils.py
>>>>>> b/bitbake/lib/bb/ui/crumbs/utils.py
>>>>>> index cd01a04..939864f 100644
>>>>>> --- a/bitbake/lib/bb/ui/crumbs/utils.py
>>>>>> +++ b/bitbake/lib/bb/ui/crumbs/utils.py
>>>>>> @@ -22,6 +22,7 @@
>>>>>> # bitbake which will allow more flexibility.
>>>>>>
>>>>>> import os
>>>>>> +import bb
>>>>> Why is this needed? I don't see any change you made in utils.py.
>>>>> Is that to say without this line, the functions in utils.py don't work?
>>>> Without the import, it just complains that
>>>>
>>>> NameError: global name 'bb' is not defined
>>>>
>>>> Regards,
>>>> Kai
>>> OK, It seems Saul didn't test it when he created utils.py;-)
>> I am not quit sure because it is fine when call the deploy image in the
>> hob. little weird.
>>
> Probably because another file in the import list includes bb.
>
> However, this change is not specific to the image tool and should be
> broken out as a separate patch. utils.py makes calls to bb.utils.which()
> on the third source line, so bb should certainly be imported in utils.py.
But I import bb in the bitbake-deployimage too. It still complains lack
of module bb.
Regards,
Kai
>
> --
> Darren
>
>
>> Regards,
>> Kai
>>
>>> --
>>> Shane
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hob2: create a standalone deploy image tool
2012-06-06 3:29 ` Kang Kai
@ 2012-06-06 5:01 ` Wang, Shane
0 siblings, 0 replies; 14+ messages in thread
From: Wang, Shane @ 2012-06-06 5:01 UTC (permalink / raw)
To: Kang Kai, Darren Hart
Cc: bitbake-devel@lists.openembedded.org, zhenfeng.zhao@windriver.com
Kang Kai wrote on 2012-06-06:
> On 2012年06月06日 01:24, Darren Hart wrote:
>>
>> On 06/05/2012 01:15 AM, Kang Kai wrote:
>>> On 2012年06月05日 15:40, Wang, Shane wrote:
>>>> Kang Kai wrote on 2012-06-05:
>>>>
>>>>> On 2012年06月05日 14:42, Wang, Shane wrote:
>>>>>>> -----Original Message-----
>>>>>>> From: Kang Kai [mailto:kai.kang@windriver.com]
>>>>>>> Sent: Tuesday, June 05, 2012 11:37 AM
>>>>>>> To: dvhart@linux.intel.com
>>>>>>> Cc: Wang, Shane; zhenfeng.zhao@windriver.com;
>>>>>>> bitbake-devel@lists.openembedded.org
>>>>>>> Subject: [PATCH 2/2] hob2: create a standalone deploy image tool
>>>>>>>
>>>>>>> diff --git a/bitbake/lib/bb/ui/crumbs/utils.py
>>>>>>> b/bitbake/lib/bb/ui/crumbs/utils.py
>>>>>>> index cd01a04..939864f 100644
>>>>>>> --- a/bitbake/lib/bb/ui/crumbs/utils.py
>>>>>>> +++ b/bitbake/lib/bb/ui/crumbs/utils.py
>>>>>>> @@ -22,6 +22,7 @@
>>>>>>> # bitbake which will allow more flexibility.
>>>>>>>
>>>>>>> import os
>>>>>>> +import bb
>>>>>> Why is this needed? I don't see any change you made in utils.py.
>>>>>> Is that to say without this line, the functions in utils.py don't work?
>>>>> Without the import, it just complains that
>>>>>
>>>>> NameError: global name 'bb' is not defined
>>>>>
>>>>> Regards,
>>>>> Kai
>>>> OK, It seems Saul didn't test it when he created utils.py;-)
>>> I am not quit sure because it is fine when call the deploy image in the
>>> hob. little weird.
>>>
>> Probably because another file in the import list includes bb.
>>
>> However, this change is not specific to the image tool and should be
>> broken out as a separate patch. utils.py makes calls to bb.utils.which()
>> on the third source line, so bb should certainly be imported in utils.py.
>
> But I import bb in the bitbake-deployimage too. It still complains lack
> of module bb.
>
> Regards,
> Kai
>
Never mind. I think the rule is you should import in the file where you use.
There is no assumption that others help to import.
Ditto in C language for including header files.
--
Shane
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2012-06-06 5:13 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-05 3:37 [PATCH 0/2] hob2: add a standalone deploy image tool Kang Kai
2012-06-05 3:37 ` [PATCH 1/2] hob2: update DeployImageDialog for seperated tool Kang Kai
2012-06-05 17:38 ` Darren Hart
2012-06-06 2:33 ` Kang Kai
2012-06-06 3:01 ` Kang Kai
2012-06-05 3:37 ` [PATCH 2/2] hob2: create a standalone deploy image tool Kang Kai
2012-06-05 6:42 ` Wang, Shane
2012-06-05 7:04 ` Kang Kai
2012-06-05 7:40 ` Wang, Shane
2012-06-05 8:15 ` Kang Kai
2012-06-05 17:24 ` Darren Hart
2012-06-06 3:29 ` Kang Kai
2012-06-06 5:01 ` Wang, Shane
2012-06-05 17:55 ` Darren Hart
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.