Patchwork [bitbake-devel] ui: Improve error message if bitbake cannot import python curses module

login
register
mail settings
Submitter Mark Hatle
Date Aug. 21, 2012, 7:17 p.m.
Message ID <1345576620-9407-1-git-send-email-mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/35115/
State Accepted
Commit 65a5845ac942d0aa6838c295e41b656f9d2a98bb
Headers show

Comments

Mark Hatle - Aug. 21, 2012, 7:17 p.m.
From: Konrad Scherer <Konrad.Scherer@windriver.com>

On some SuSE systems, the curses python module is not installed by default.
Instead of a python failure, we want a nicer error message.

(On SuSE systems the package is typically python-curses.)

Signed-off-by: Konrad Scherer <Konrad.Scherer@windriver.com>
Signed-off-by: Jeff Polk <jeff.polk@windriver.com>

Reword commit message, rebase to latest bitbake.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
 lib/bb/ui/knotty.py  |    6 +++++-
 lib/bb/ui/ncurses.py |    8 +++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

Patch

diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index b01daee..858cacf 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -141,7 +141,11 @@  class TerminalFilter(object):
         if not self.interactive:
             return
 
-        import curses
+        try:
+            import curses
+        except ImportError:
+            sys.exit("FATAL: The knotty ui could not load the required curses python module.")
+	
         import termios
         self.curses = curses
         self.termios = termios
diff --git a/lib/bb/ui/ncurses.py b/lib/bb/ui/ncurses.py
index 1425bbd..f573b95 100644
--- a/lib/bb/ui/ncurses.py
+++ b/lib/bb/ui/ncurses.py
@@ -47,7 +47,13 @@ 
 
 from __future__ import division
 import logging
-import os, sys, curses, itertools, time, subprocess
+import os, sys, itertools, time, subprocess
+
+try:
+    import curses
+except ImportError:
+    sys.exit("FATAL: The ncurses ui could not load the required curses python module.")
+
 import bb
 import xmlrpclib
 from bb import ui