Patchwork [07/15] bin/bitbake: Ensure early errors are shown to the user

login
register
mail settings
Submitter Richard Purdie
Date May 7, 2013, 12:55 p.m.
Message ID <1367931368-21504-7-git-send-email-richard.purdie@linuxfoundation.org>
Download mbox | patch
Permalink /patch/49451/
State New
Headers show

Comments

Richard Purdie - May 7, 2013, 12:55 p.m.
Currently if errors occur early in the init process, the errors may
not be shown to the user. This change ensures that if a failure does
occur, the messages are flushed from the queue and shown to the user.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 bitbake/bin/bitbake |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
Jonathan Liu - May 13, 2013, 1:31 a.m.
On 7 May 2013 22:55, Richard Purdie <richard.purdie@linuxfoundation.org>wrote:

> Currently if errors occur early in the init process, the errors may
> not be shown to the user. This change ensures that if a failure does
> occur, the messages are flushed from the queue and shown to the user.
>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  bitbake/bin/bitbake |   21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
> index 0e69207..e05ff5b 100755
> --- a/bitbake/bin/bitbake
> +++ b/bitbake/bin/bitbake
> @@ -240,11 +240,22 @@ Default BBFILES are the .bb files in the current
> directory.""")
>
>      idle = server.getServerIdleCB()
>
> -    cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
> -    cooker.parseCommandLine()
> -
> -    server.addcooker(cooker)
> -    server.saveConnectionDetails()
> +    try:
> +        cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
> +        cooker.parseCommandLine()
> +
> +        server.addcooker(cooker)
> +        server.saveConnectionDetails()
> +    except:
> +        while True:
> +            import queue
>
import queue is Python 3. It is import Queue in Python 2.
If I run bitbake when it is already running, I get:

ImportError: No module named queue
ERROR: Only one copy of bitbake should be run against a build directory


> +            try:
> +                event = server.event_queue.get(block=False)
> +            except (queue.Empty, IOError):
> +                break
> +            if isinstance(event, logging.LogRecord):
> +                logger.handle(event)
> +        raise
>      server.detach()
>
>      # Should no longer need to ever reference cooker
> --
> 1.7.10.4
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>

Regards,
Jonathan

Patch

diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 0e69207..e05ff5b 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -240,11 +240,22 @@  Default BBFILES are the .bb files in the current directory.""")
 
     idle = server.getServerIdleCB()
 
-    cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
-    cooker.parseCommandLine()
-
-    server.addcooker(cooker)
-    server.saveConnectionDetails()
+    try:
+        cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
+        cooker.parseCommandLine()
+
+        server.addcooker(cooker)
+        server.saveConnectionDetails()
+    except:
+        while True:
+            import queue
+            try:
+                event = server.event_queue.get(block=False)
+            except (queue.Empty, IOError):
+                break
+            if isinstance(event, logging.LogRecord):
+                logger.handle(event)
+        raise
     server.detach()
 
     # Should no longer need to ever reference cooker