Patchwork [bitbake-devel] HOB:Proper handle of SIGINT

login
register
mail settings
Submitter Valentin Popa
Date July 3, 2013, 11:31 a.m.
Message ID <1372851104-27705-1-git-send-email-valentin.popa@intel.com>
Download mbox | patch
Permalink /patch/52881/
State New
Headers show

Comments

Valentin Popa - July 3, 2013, 11:31 a.m.
Modal dialogs doesn't run on the main loop so they cannot
catch any signal from the terminal. This patch makes sure
the dialogs are destroyed when a SIGINT is sent to HOB.

[YOCTO #3329]
Signed-off-by: Valentin Popa <valentin.popa@intel.com>
---
 bitbake/lib/bb/ui/crumbs/builder.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
Paul Eggleton - July 5, 2013, 3:02 p.m.
Hi Valentin,

On Wednesday 03 July 2013 14:31:44 Valentin Popa wrote:
> Modal dialogs doesn't run on the main loop so they cannot
> catch any signal from the terminal. This patch makes sure
> the dialogs are destroyed when a SIGINT is sent to HOB.
> 
> [YOCTO #3329]
> Signed-off-by: Valentin Popa <valentin.popa@intel.com>
> ---
>  bitbake/lib/bb/ui/crumbs/builder.py | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/bitbake/lib/bb/ui/crumbs/builder.py
> b/bitbake/lib/bb/ui/crumbs/builder.py index d5df60f..a2abb2a 100755
> --- a/bitbake/lib/bb/ui/crumbs/builder.py
> +++ b/bitbake/lib/bb/ui/crumbs/builder.py
> @@ -30,6 +30,7 @@ import shlex
>  import re
>  import logging
>  import sys
> +import signal
>  from bb.ui.crumbs.imageconfigurationpage import ImageConfigurationPage
>  from bb.ui.crumbs.recipeselectionpage import RecipeSelectionPage
>  from bb.ui.crumbs.packageselectionpage import PackageSelectionPage
> @@ -441,6 +442,8 @@ class Builder(gtk.Window):
> 
>          self.initiate_new_build_async()
> 
> +        signal.signal(signal.SIGINT, self.event_handle_SIGINT)
> +
>      def create_visual_elements(self):
>          self.set_title("Hob")
>          self.set_icon_name("applications-development")
> @@ -1028,7 +1031,7 @@ class Builder(gtk.Window):
>          dialog.destroy()
>          self.build_failed()
> 
> -    def handler_task_started_cb(self, running_build, message):
> +    def handler_task_started_cb(self, running_build, message):
>          fraction = message["current"] * 1.0/message["total"]
>          title = "Build packages"
>          if self.current_step == self.FAST_IMAGE_GENERATING:
> @@ -1075,6 +1078,12 @@ class Builder(gtk.Window):
>          else:
>              gtk.main_quit()
> 
> +    def event_handle_SIGINT(self, signal, frame):
> +        for w in gtk.window_list_toplevels():
> +            if w.get_modal():
> +                w.response(gtk.RESPONSE_DELETE_EVENT)
> +        sys.exit(0)
> +
>      def build_packages(self):
>          _, all_recipes = self.recipe_model.get_selected_recipes()
>          if not all_recipes:
> @@ -1090,7 +1099,7 @@ class Builder(gtk.Window):
> 
>      def build_image(self):
>          selected_packages = self.package_model.get_selected_packages()
> -        if not selected_packages:
> +        if not selected_packages:
>              lbl = "<b>No selections made</b>\nYou have not made any
> selections" lbl = lbl + " so there isn't anything to bake at this time."
> dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)

This patch has been merged, however without the unrelated whitespace changes. 
If we want to make whitespace changes they should be done in a separate patch.

Cheers,
Paul

Patch

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index d5df60f..a2abb2a 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -30,6 +30,7 @@  import shlex
 import re
 import logging
 import sys
+import signal
 from bb.ui.crumbs.imageconfigurationpage import ImageConfigurationPage
 from bb.ui.crumbs.recipeselectionpage import RecipeSelectionPage
 from bb.ui.crumbs.packageselectionpage import PackageSelectionPage
@@ -441,6 +442,8 @@  class Builder(gtk.Window):
 
         self.initiate_new_build_async()
 
+        signal.signal(signal.SIGINT, self.event_handle_SIGINT)
+
     def create_visual_elements(self):
         self.set_title("Hob")
         self.set_icon_name("applications-development")
@@ -1028,7 +1031,7 @@  class Builder(gtk.Window):
         dialog.destroy()
         self.build_failed()
 
-    def handler_task_started_cb(self, running_build, message): 
+    def handler_task_started_cb(self, running_build, message):
         fraction = message["current"] * 1.0/message["total"]
         title = "Build packages"
         if self.current_step == self.FAST_IMAGE_GENERATING:
@@ -1075,6 +1078,12 @@  class Builder(gtk.Window):
         else:
             gtk.main_quit()
 
+    def event_handle_SIGINT(self, signal, frame):
+        for w in gtk.window_list_toplevels():
+            if w.get_modal():
+                w.response(gtk.RESPONSE_DELETE_EVENT)
+        sys.exit(0)
+
     def build_packages(self):
         _, all_recipes = self.recipe_model.get_selected_recipes()
         if not all_recipes:
@@ -1090,7 +1099,7 @@  class Builder(gtk.Window):
 
     def build_image(self):
         selected_packages = self.package_model.get_selected_packages()
-        if not selected_packages:      
+        if not selected_packages:
             lbl = "<b>No selections made</b>\nYou have not made any selections"
             lbl = lbl + " so there isn't anything to bake at this time."
             dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)