Patchwork [bitbake-devel,1/3] Hob: clear the repeated function get_kernel_file_name

login
register
mail settings
Submitter An, LimingX L
Date June 1, 2012, 10:40 a.m.
Message ID <57f497956749ad3a4c41051cb12f7a3b97f0254e.1338546445.git.limingx.l.an@intel.com>
Download mbox | patch
Permalink /patch/29083/
State New
Headers show

Comments

An, LimingX L - June 1, 2012, 10:40 a.m.
there are a repeated function in builder.py and imagedetailspage.py,
so combine them to one.

Signed-off-by: Liming An <limingx.l.an@intel.com>
---
 bitbake/lib/bb/ui/crumbs/builder.py          |    5 +++--
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py |   19 +------------------
 2 files changed, 4 insertions(+), 20 deletions(-)

Patch

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index 8d35ea9..899d0e0 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -1141,9 +1141,10 @@  class Builder(gtk.Window):
         response = dialog.run()
         dialog.destroy()
 
-    def get_kernel_file_name(self, image_path):
+    def get_kernel_file_name(self):
         name_list = []
         kernel_name = ""
+        image_path = self.parameters.image_addr
         if image_path:
             files = [f for f in os.listdir(image_path) if f[0] <> '.']
             for check_file in files:
@@ -1166,7 +1167,7 @@  class Builder(gtk.Window):
             dialog.destroy()
             return
 
-        kernel_name, kernels_number = self.get_kernel_file_name(self.parameters.image_addr)
+        kernel_name, kernels_number = self.get_kernel_file_name()
         if not kernel_name or kernels_number > 1:
             dialog = gtk.FileChooserDialog("Load Kernel Files", self,
                                            gtk.FILE_CHOOSER_ACTION_SAVE)
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index deb053c..1ab80f8 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -368,7 +368,7 @@  class ImageDetailsPage (HobPage):
         iter = model.get_iter(path)
         image_name = model[path][0]
         if iter and model[path][2] == 'runnable':
-            kernel_name, kernel_number = self.get_kernel_file_name(image_name)
+            kernel_name, kernel_number = self.builder.parameters.get_kernel_file_name()
             self.builder.runqemu_image(image_name, kernel_name, kernel_number)
 
     def create_bottom_buttons(self, buttonlist, image_name):
@@ -446,23 +446,6 @@  class ImageDetailsPage (HobPage):
             button_id = build_new_button.connect("clicked", self.build_new_button_clicked_cb)
             self.button_ids[button_id] = build_new_button
 
-    def get_kernel_file_name(self, image_name):
-        name_list = []
-        kernel_name = ""
-        if image_name:
-            image_path = os.path.join(self.builder.parameters.image_addr)
-            files = [f for f in os.listdir(image_path) if f[0] <> '.']
-            for check_file in files:
-                if check_file.endswith(".bin"):
-                    if  self.test_mach_runnable(check_file):
-                        selected_machine = self.builder.configuration.curr_mach
-                        if selected_machine in check_file:
-                            kernel_name = check_file
-                    if not os.path.islink(os.path.join(image_path, check_file)):
-                        name_list.append(check_file)
-
-        return kernel_name, len(name_list)
-
     def save_button_clicked_cb(self, button):
         self.builder.show_save_template_dialog()