[OE-core] [PATCH 1/3] scriptutils: exit politely when no text editor available

Chang Rebecca Swee Fun rebecca.swee.fun.chang at intel.com
Wed Jun 28 01:59:17 UTC 2017

devtool edit-recipe now has ugly tracebacks if executed without an
editor available. This happens in the build containers whenever no
text editor is available.

subprocess.check_call will run text editing command with recipe path
provided. It will wait for command to complete. If the return code
was zero then return, otherwise raise CalledProcessError exception.

This enhancement will suppress the traceback by catching the exception
and prompt the error messages in a proper manner shown below:

pokyuser at 59c99c507238:/workdir/docker-dbg$ devtool edit-recipe ifupdown
/bin/sh: 1: vi: not found
ERROR: Execution of 'vi' failed: Command 'vi
returned non-zero exit status 127

[YOCTO #11434]

Signed-off-by: Chang Rebecca Swee Fun <rebecca.swee.fun.chang at intel.com>
 scripts/lib/scriptutils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py
index 92b601c..2b3f3fc 100644
--- a/scripts/lib/scriptutils.py
+++ b/scripts/lib/scriptutils.py
@@ -134,8 +134,8 @@ def run_editor(fn):
     editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi'))
         return subprocess.check_call('%s %s' % (editor, params), shell=True)
-    except OSError as exc:
-        logger.error("Execution of editor '%s' failed: %s", editor, exc)
+    except subprocess.CalledProcessError as exc:
+        logger.error("Execution of '%s' failed: %s" % (editor, exc))
         return 1
 def is_src_url(param):

More information about the Openembedded-core mailing list