[oe-commits] [bitbake] 02/05: toasterui: capture keyboard interrupts the same way as knotty

git at git.openembedded.org git at git.openembedded.org
Tue May 17 14:25:37 UTC 2016


rpurdie pushed a commit to branch master
in repository bitbake.

commit d39d2edca95900da433074ee95a192d7bfe7090d
Author: Elliot Smith <elliot.smith at intel.com>
AuthorDate: Thu May 12 15:10:37 2016 +0100

    toasterui: capture keyboard interrupts the same way as knotty
    
    knotty captures two levels of keyboard interrupt: a single interrupt
    or two interrupts in a row. These then trigger stateShutdown
    and stateForceShutdown respectively.
    
    toasterui doesn't have an equivalent way of capturing interrupts and
    using them to shut down bitbake. Now that we are no longer using
    knotty + XMLRPCServer for our command line builds (since switching to
    per-project build directories), we see some odd side effects of this,
    such as builds continuing after they have been interrupted on the
    command line.
    
    Bring toasterui in line with knotty (copy-paste most of the code
    in knotty.py which deals with interrupts) so that a keyboard
    interrupt actually shuts down the bitbake server (if not in
    observe only mode).
    
    Additionally use the cancel_cli_build() method to set the Build
    status to CANCELLED in Toaster's db when we get keyboard interrupts.
    This means that builds interrupted on the command line show as
    cancelled (same as if they'd been cancelled from the Toaster UI),
    as specified in the UI designs.
    
    [YOCTO #8515]
    
    Signed-off-by: Elliot Smith <elliot.smith at intel.com>
    Signed-off-by: Michael Wood <michael.g.wood at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/ui/toasterui.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/bb/ui/toasterui.py b/lib/bb/ui/toasterui.py
index c2d41f7..5382935 100644
--- a/lib/bb/ui/toasterui.py
+++ b/lib/bb/ui/toasterui.py
@@ -441,7 +441,22 @@ def main(server, eventHandler, params):
             if ioerror.args[0] == 4:
                 pass
         except KeyboardInterrupt:
-            main.shutdown = 1
+            if params.observe_only:
+                print("\nKeyboard Interrupt, exiting observer...")
+                main.shutdown = 2
+            if not params.observe_only and main.shutdown == 1:
+                print("\nSecond Keyboard Interrupt, stopping...\n")
+                _, error = server.runCommand(["stateForceShutdown"])
+                if error:
+                    logger.error("Unable to cleanly stop: %s" % error)
+            if not params.observe_only and main.shutdown == 0:
+                print("\nKeyboard Interrupt, closing down...\n")
+                interrupted = True
+                _, error = server.runCommand(["stateShutdown"])
+                if error:
+                    logger.error("Unable to cleanly shutdown: %s" % error)
+            buildinfohelper.cancel_cli_build()
+            main.shutdown = main.shutdown + 1
         except Exception as e:
             # print errors to log
             import traceback

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list