]> code.ossystems Code Review - openembedded-core.git/commitdiff
devshell: list commands when throwing NoSupportedTerminals
authorStephano Cetola <stephano.cetola@linux.intel.com>
Tue, 15 Nov 2016 02:30:11 +0000 (18:30 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Nov 2016 11:02:28 +0000 (11:02 +0000)
When attempting to run devshell, if no terminal is available, the
error being thrown was not very specific. This adds a list of
commands that failed, informing the user of what they can install to
fix the error.

[ YOCTO #10472]

Signed-off-by: Stephano Cetola <stephano.cetola@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/terminal.bbclass
meta/lib/oe/terminal.py

index a94f755a40f347c14b1b9ade37ed59ac984aec45..cd8d124507756b1c21ed7a178904d56510e5dedd 100644 (file)
@@ -88,8 +88,12 @@ def oe_terminal(command, title, d):
 
     try:
         oe.terminal.spawn_preferred(command, title, None, d)
-    except oe.terminal.NoSupportedTerminals:
-        bb.fatal('No valid terminal found, unable to open devshell')
+    except oe.terminal.NoSupportedTerminals as nosup:
+        nosup.terms.remove("false")
+        cmds = '\n\t'.join(nosup.terms).replace("{command}",
+                    "do_terminal").replace("{title}", title)
+        bb.fatal('No valid terminal found, unable to open devshell.\n' +
+                'Tried the following commands:\n\t%s' % cmds)
     except oe.terminal.ExecutionError as exc:
         bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc))
 
index 7446c44c49336e991f37d598c2a62943003a83bb..38e66cef1ff42d2cbfb18ad53d2ae7398e8410fb 100644 (file)
@@ -11,7 +11,8 @@ class UnsupportedTerminal(Exception):
     pass
 
 class NoSupportedTerminals(Exception):
-    pass
+    def __init__(self, terms):
+        self.terms = terms
 
 
 class Registry(oe.classutils.ClassRegistry):
@@ -209,6 +210,14 @@ class Custom(Terminal):
 def prioritized():
     return Registry.prioritized()
 
+def get_cmd_list():
+    terms = Registry.prioritized()
+    cmds = []
+    for term in terms:
+        if term.command:
+            cmds.append(term.command)
+    return cmds
+
 def spawn_preferred(sh_cmd, title=None, env=None, d=None):
     """Spawn the first supported terminal, by priority"""
     for terminal in prioritized():
@@ -218,7 +227,7 @@ def spawn_preferred(sh_cmd, title=None, env=None, d=None):
         except UnsupportedTerminal:
             continue
     else:
-        raise NoSupportedTerminals()
+        raise NoSupportedTerminals(get_cmd_list())
 
 def spawn(name, sh_cmd, title=None, env=None, d=None):
     """Spawn the specified terminal, by name"""