Skip to contentSkip to conversation

hob2: add a standalone deploy image tool

PATCH In review Kang Kai 3 participants 14 messages Jun 5, 2012 – Jun 6, 2012

lore
Share & tools
lore

Kang Kai

author
#0 lore raw

cover hob2: add a standalone deploy image tool

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
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 1/2 hob2: update DeployImageDialog for seperated tool

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.

---
 bitbake/lib/bb/ui/crumbs/hig.py |   82 ++++++++++++++++++++++++++++++++-------
 1 files changed, 68 insertions(+), 14 deletions(-)
bitbake/lib/bb/ui/crumbs/hig.py +68 -14
index 7c9e73f..7d8daad 100644
@@ -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):
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [PATCH 1/2] hob2: update DeployImageDialog for seperated tool

Quoted 8 lines · Kang Kai

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.

Quoted 46 lines

Remove some extra spaces at same time.

---
 bitbake/lib/bb/ui/crumbs/hig.py |   82 ++++++++++++++++++++++++++++++++-------
 1 files changed, 68 insertions(+), 14 deletions(-)
bitbake/lib/bb/ui/crumbs/hig.py +5 -2
index 7c9e73f..7d8daad 100644
@@ -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()

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 773

Quoted 10 lines
bitbake/lib/bb/ui/crumbs/hig.py +5 -0
         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.

Quoted 21 lines
bitbake/lib/bb/ui/crumbs/hig.py +9 -4
         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()

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 800

Quoted 10 lines
bitbake/lib/bb/ui/crumbs/hig.py +10 -0
+                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?

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 815

Quoted 8 lines
bitbake/lib/bb/ui/crumbs/hig.py +1 -1
         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...

Quoted 11 lines
bitbake/lib/bb/ui/crumbs/hig.py +4 -0
         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):

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 838

Quoted 10 lines
bitbake/lib/bb/ui/crumbs/hig.py +3 -1
+        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.

Quoted 30 lines
bitbake/lib/bb/ui/crumbs/hig.py +10 -3
             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)

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 880

Quoted 10 lines
bitbake/lib/bb/ui/crumbs/hig.py +10 -0
+                    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?

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 882

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"

"<b>No selection made.</b>\nPlease select a device."

Again, why are we limiting devices to USB devices?

Quoted 36 lines
bitbake/lib/bb/ui/crumbs/hig.py +9 -3
+            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):
Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
author
#3 lore raw

Re: [PATCH 1/2] hob2: update DeployImageDialog for seperated tool

Quoted 10 lines · Darren Hart
Quoted 8 lines · Kang Kai

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.

Quoted 3 lines

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.

Quoted 51 lines
Quoted 51 lines

Remove some extra spaces at same time.

---
  bitbake/lib/bb/ui/crumbs/hig.py |   82 ++++++++++++++++++++++++++++++++-------
  1 files changed, 68 insertions(+), 14 deletions(-)
bitbake/lib/bb/ui/crumbs/hig.py +5 -2
index 7c9e73f..7d8daad 100644
@@ -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)
 
Quoted 11 lines

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 773

Quoted 5 lines
bitbake/lib/bb/ui/crumbs/hig.py +5 -0
+        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.

Quoted 27 lines
Quoted 27 lines
bitbake/lib/bb/ui/crumbs/hig.py +13 -4
          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)
Quoted 8 lines

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 800

Quoted 6 lines
bitbake/lib/bb/ui/crumbs/hig.py +6 -0
+                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.

Quoted 29 lines

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 815

Quoted 9 lines
bitbake/lib/bb/ui/crumbs/hig.py +1 -1
          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...

Quoted 17 lines
bitbake/lib/bb/ui/crumbs/hig.py +6 -0
          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()
 
Quoted 8 lines

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 838

Quoted 4 lines
bitbake/lib/bb/ui/crumbs/hig.py +1 -1
      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.

Quoted 43 lines
Quoted 31 lines
bitbake/lib/bb/ui/crumbs/hig.py +10 -3
              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)

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 880

Quoted 10 lines
bitbake/lib/bb/ui/crumbs/hig.py +10 -0
+                    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."

Quoted 1 line

Is<br> appropriate here instead of \n?

Ok, thanks.

Quoted 6 lines

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 882

Quoted 3 lines
bitbake/lib/bb/ui/crumbs/hig.py +2 -0
+                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

Quoted 37 lines
Quoted 37 lines
bitbake/lib/bb/ui/crumbs/hig.py +9 -3
+            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):
author
#4 lore raw

Re: [PATCH 1/2] hob2: update DeployImageDialog for seperated tool

Quoted 235 lines · Kang Kai
Quoted 10 lines · Darren Hart
Quoted 8 lines · Kang Kai

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.

Quoted 3 lines

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.

Quoted 59 lines
Quoted 59 lines

Remove some extra spaces at same time.

---
  bitbake/lib/bb/ui/crumbs/hig.py |   82 
++++++++++++++++++++++++++++++++-------
  1 files changed, 68 insertions(+), 14 deletions(-)
bitbake/lib/bb/ui/crumbs/hig.py +1 -0
index 7c9e73f..7d8daad 100644
@@ -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

bitbake/lib/bb/ui/crumbs/hig.py +1 -1
@@ -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)

bitbake/lib/bb/ui/crumbs/hig.py +0 -1
@@ -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

bitbake/lib/bb/ui/crumbs/hig.py +2 -0
+        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)

Quoted 11 lines

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 773

Quoted 5 lines
bitbake/lib/bb/ui/crumbs/hig.py +5 -0
+        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.

Quoted 31 lines
Quoted 31 lines

scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN)

bitbake/lib/bb/ui/crumbs/hig.py +15 -4
@@ -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)
Quoted 8 lines
Quoted 6 lines
bitbake/lib/bb/ui/crumbs/hig.py +4 -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.

Quoted 30 lines

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 815

Quoted 9 lines

self.usb_desc = gtk.Label()
self.usb_desc.set_alignment(0.0, 0.5)

bitbake/lib/bb/ui/crumbs/hig.py +1 -1
@@ -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...

Quoted 18 lines
bitbake/lib/bb/ui/crumbs/hig.py +0 -0
          self.vbox.pack_start(self.usb_desc, expand=False, 
 fill=False, padding=2)
 

self.progress_bar = HobProgressBar()

bitbake/lib/bb/ui/crumbs/hig.py +6 -0
@@ -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()
 
Quoted 9 lines

bitbake/lib/bb/ui/crumbs/hig.py class DeployImageDialog (CrumbsDialog): · line 838

Quoted 5 lines
bitbake/lib/bb/ui/crumbs/hig.py +1 -1
      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.

Quoted 51 lines
Quoted 48 lines
bitbake/lib/bb/ui/crumbs/hig.py +3 -0
              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__:

bitbake/lib/bb/ui/crumbs/hig.py +2 -1
@@ -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 + "\""

bitbake/lib/bb/ui/crumbs/hig.py +2 -1
-                    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))

bitbake/lib/bb/ui/crumbs/hig.py +6 -0
+                    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"

bitbake/lib/bb/ui/crumbs/hig.py +6 -0
+                    tmpfile.close()
+                    os.remove(tmpname)
+
+            else:
+                if not self.image_path:
+                    lbl = "<b>No selection made</b>\nYou have not 
Quoted 1 line

selected image to deploy"

"<b>No selection made.</b>\nPlease select an image."

Quoted 3 lines
Quoted 1 line

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

Quoted 61 lines
Quoted 8 lines
Quoted 5 lines
bitbake/lib/bb/ui/crumbs/hig.py +2 -0
+                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

Quoted 42 lines
Quoted 42 lines
bitbake/lib/bb/ui/crumbs/hig.py +2 -0
+            if len(lbl):
+                crumbs_dialog = CrumbsMessageDialog(self, lbl, 

gtk.STOCK_DIALOG_INFO)
+ button = crumbs_dialog.add_button("Close",
gtk.RESPONSE_OK)

bitbake/lib/bb/ui/crumbs/hig.py +4 -1
+                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)
bitbake/lib/bb/ui/crumbs/hig.py +1 -1
@@ -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)

bitbake/lib/bb/ui/crumbs/hig.py +2 -1
@@ -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)
 
Quoted 1 line
Quoted 1 line

class ProxyDetailsDialog (CrumbsDialog):

_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/bitbake-devel

author
#5 lore raw

PATCH 2/2 hob2: create a standalone deploy image tool

In reply to Kang Kai

[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.

---
 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
bitbake/bin/bitbake-deployimage new file +135 -0
new file mode 100755
index 0000000..8fdd21b
@@ -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)
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
index cd01a04..939864f 100644
@@ -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
#6 lore raw

Re: [PATCH 2/2] hob2: create a standalone deploy image tool

Quoted 38 lines

-----Original Message-----
From: Kang Kai [mailto:[email protected]]
Sent: Tuesday, June 05, 2012 11:37 AM
To: [email protected]
Cc: Wang, Shane; [email protected]; [email protected]
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.

---
 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
bitbake/bin/bitbake-deployimage new file +4 -0
new file mode 100755
index 0000000..8fdd21b
@@ -0,0 +1,135 @@
+#!/usr/bin/python
+
+
+requirements = "FATAL: Gtk+ 2.20.0 or higher, PyGtk version 2.22.0 or higher
Quoted 1 line

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.

bitbake/lib/bb/ui/crumbs/utils.py line 25

Quoted 10 lines
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
index cd01a04..939864f 100644
@@ -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?

Quoted 5 lines
bitbake/lib/bb/ui/crumbs/utils.py +0 -1
 def which_terminal():
     term = bb.utils.which(os.environ["PATH"], "xterm")
--

1.7.5.4

author
#7 lore raw

Re: [PATCH 2/2] hob2: create a standalone deploy image tool

Quoted 27 lines · Shane
Quoted 27 lines

-----Original Message-----
From: Kang Kai [mailto:[email protected]]
Sent: Tuesday, June 05, 2012 11:37 AM
To: [email protected]
Cc: Wang, Shane; [email protected]; [email protected]
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.

---
  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

Quoted 12 lines
Quoted 11 lines
bitbake/bin/bitbake-deployimage new file +4 -0
new file mode 100755
index 0000000..8fdd21b
@@ -0,0 +1,135 @@
+#!/usr/bin/python
+
+
+requirements = "FATAL: Gtk+ 2.20.0 or higher, PyGtk version 2.22.0 or higher
Quoted 1 line

and PyGobject are required to use Hob"

Hi Shane,

Quoted 3 lines

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.

Quoted 11 lines
Quoted 11 lines
bitbake/lib/bb/ui/crumbs/utils.py +0 -0
index cd01a04..939864f 100644
@@ -22,6 +22,7 @@
  # bitbake which will allow more flexibility.
 
Quoted 4 lines

bitbake/lib/bb/ui/crumbs/utils.py line 25

Quoted 2 lines
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
  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

Quoted 6 lines
Quoted 5 lines
bitbake/lib/bb/ui/crumbs/utils.py +0 -1
  def which_terminal():
      term = bb.utils.which(os.environ["PATH"], "xterm")
--

1.7.5.4

#8 lore raw

Re: [PATCH 2/2] hob2: create a standalone deploy image tool

Kang Kai wrote on 2012-06-05:

Quoted 22 lines · Shane
Quoted 16 lines
Quoted 16 lines

-----Original Message-----
From: Kang Kai [mailto:[email protected]]
Sent: Tuesday, June 05, 2012 11:37 AM
To: [email protected]
Cc: Wang, Shane; [email protected]; [email protected]
Subject: [PATCH 2/2] hob2: create a standalone deploy image tool

bitbake/lib/bb/ui/crumbs/utils.py +0 -0
index cd01a04..939864f 100644
@@ -22,6 +22,7 @@
  # bitbake which will allow more flexibility.
 
Quoted 4 lines

bitbake/lib/bb/ui/crumbs/utils.py line 25

Quoted 2 lines
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
  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?

Quoted 6 lines

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

author
#9 lore raw

Re: [PATCH 2/2] hob2: create a standalone deploy image tool

Quoted 23 lines · Shane

Kang Kai wrote on 2012-06-05:

Quoted 21 lines · Shane
Quoted 20 lines
Quoted 14 lines

-----Original Message-----
From: Kang Kai [mailto:[email protected]]
Sent: Tuesday, June 05, 2012 11:37 AM
To: [email protected]
Cc: Wang, Shane; [email protected]; [email protected]
Subject: [PATCH 2/2] hob2: create a standalone deploy image tool

bitbake/lib/bb/ui/crumbs/utils.py +0 -0
index cd01a04..939864f 100644

bitbake/lib/bb/ui/crumbs/utils.py line 25

Quoted 4 lines
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
@@ -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?

Quoted 7 lines
Quoted 6 lines

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

Quoted 3 lines

--
Shane

#10 lore raw

Re: [PATCH 2/2] hob2: create a standalone deploy image tool

Quoted 26 lines · Kang Kai
Quoted 25 lines · Shane

Kang Kai wrote on 2012-06-05:

Quoted 23 lines · Shane
Quoted 16 lines
Quoted 16 lines

-----Original Message-----
From: Kang Kai [mailto:[email protected]]
Sent: Tuesday, June 05, 2012 11:37 AM
To: [email protected]
Cc: Wang, Shane; [email protected]; [email protected]
Subject: [PATCH 2/2] hob2: create a standalone deploy image tool

bitbake/lib/bb/ui/crumbs/utils.py +0 -0
index cd01a04..939864f 100644
@@ -22,6 +22,7 @@
   # bitbake which will allow more flexibility.
 
Quoted 4 lines

bitbake/lib/bb/ui/crumbs/utils.py line 25

Quoted 2 lines
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
   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

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 7 lines

Regards,
Kai

Quoted 3 lines

--
Shane

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
author
#11 lore raw

Re: [PATCH 2/2] hob2: create a standalone deploy image tool

Quoted 33 lines · Darren Hart
Quoted 31 lines · Kang Kai
Quoted 30 lines · Shane

Kang Kai wrote on 2012-06-05:

Quoted 21 lines · Shane
Quoted 16 lines
Quoted 16 lines

-----Original Message-----
From: Kang Kai [mailto:[email protected]]
Sent: Tuesday, June 05, 2012 11:37 AM
To: [email protected]
Cc: Wang, Shane; [email protected]; [email protected]
Subject: [PATCH 2/2] hob2: create a standalone deploy image tool

bitbake/lib/bb/ui/crumbs/utils.py +0 -0
index cd01a04..939864f 100644
@@ -22,6 +22,7 @@
    # bitbake which will allow more flexibility.
 
Quoted 4 lines

bitbake/lib/bb/ui/crumbs/utils.py line 25

Quoted 2 lines
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
    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?

Quoted 6 lines

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;-)

Quoted 8 lines
Quoted 3 lines

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

Quoted 10 lines

--
Darren

Quoted 5 lines

Regards,
Kai

Quoted 2 lines

--
Shane

#12 lore raw

Re: [PATCH 2/2] hob2: create a standalone deploy image tool

Kang Kai wrote on 2012-06-06:

Quoted 43 lines · Darren Hart
Quoted 33 lines · Kang Kai
Quoted 31 lines · Shane
Quoted 30 lines

Kang Kai wrote on 2012-06-05:

Quoted 21 lines · Shane
Quoted 16 lines
Quoted 16 lines

-----Original Message-----
From: Kang Kai [mailto:[email protected]]
Sent: Tuesday, June 05, 2012 11:37 AM
To: [email protected]
Cc: Wang, Shane; [email protected]; [email protected]
Subject: [PATCH 2/2] hob2: create a standalone deploy image tool

bitbake/lib/bb/ui/crumbs/utils.py +0 -0
index cd01a04..939864f 100644
@@ -22,6 +22,7 @@
    # bitbake which will allow more flexibility.
 
Quoted 4 lines

bitbake/lib/bb/ui/crumbs/utils.py line 25

Quoted 2 lines
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
    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?

Quoted 6 lines

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;-)

Quoted 8 lines
Quoted 3 lines

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.

Quoted 6 lines

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

#13 lore raw

Re: [PATCH 2/2] hob2: create a standalone deploy image tool

In reply to Kang Kai
Quoted 10 lines · Kang Kai

[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.

bitbake/bin/bitbake-deployimage

Quoted 13 lines
---
 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
bitbake/bin/bitbake-deployimage new file +0 -0
new file mode 100755
index 0000000..8fdd21b

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.

bitbake/bin/bitbake-deployimage line 1

Quoted 2 lines
bitbake/bin/bitbake-deployimage new file +1 -0
@@ -0,0 +1,135 @@
+#!/usr/bin/python

This should be:

#!/usr/bin/env python

Quoted 11 lines
bitbake/bin/bitbake-deployimage new file +11 -0
+
+# 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.

bitbake/bin/bitbake-deployimage line 22

Quoted 10 lines
bitbake/bin/bitbake-deployimage new file +10 -0
+#
+# 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

Quoted 18 lines
bitbake/bin/bitbake-deployimage new file +18 -0
+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:

bitbake/bin/bitbake-deployimage line 50

Quoted 10 lines
bitbake/bin/bitbake-deployimage new file +10 -0
+    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.

bitbake/bin/bitbake-deployimage line 60

Quoted 10 lines
bitbake/bin/bitbake-deployimage 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</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)

bitbake/bin/bitbake-deployimage line 66

Quoted 6 lines
bitbake/bin/bitbake-deployimage 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</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)

bitbake/bin/bitbake-deployimage line 78

Quoted 12 lines
bitbake/bin/bitbake-deployimage new file +12 -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()
+                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.

Quoted 13 lines
bitbake/bin/bitbake-deployimage new file +13 -0
+        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()

bitbake/bin/bitbake-deployimage line 101

Quoted 10 lines
bitbake/bin/bitbake-deployimage new file +10 -0
+        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?

Quoted 12 lines
bitbake/bin/bitbake-deployimage new file +12 -0
+                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)

bitbake/bin/bitbake-deployimage line 123

Quoted 10 lines
bitbake/bin/bitbake-deployimage new file +10 -0
+
+        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.

Quoted 17 lines
bitbake/bin/bitbake-deployimage new file +12 -0
+
+    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)
bitbake/lib/bb/ui/crumbs/utils.py +0 -0
index cd01a04..939864f 100644

bitbake/lib/bb/ui/crumbs/utils.py line 25

Quoted 4 lines
bitbake/lib/bb/ui/crumbs/utils.py +1 -0
@@ -22,6 +22,7 @@
 # bitbake which will allow more flexibility.
 
 import os
+import bb

separate patch.

Quoted 3 lines
bitbake/lib/bb/ui/crumbs/utils.py +0 -0
 def which_terminal():
     term = bb.utils.which(os.environ["PATH"], "xterm")
Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel