summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorChang Rebecca Swee Fun <rebecca.swee.fun.chang@intel.com>2017-06-28 09:59:17 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-21 22:51:37 +0100
commit2c035b266f7a7f904afa7698706eba1361b41411 (patch)
tree4ccaa437a2d2472d97880e8137e27c82aec82314 /scripts
parent50ef2da7ca4dcf50ae527f92ae387d4e5277a63d (diff)
downloadpoky-2c035b266f7a7f904afa7698706eba1361b41411.tar.gz
scriptutils: exit politely when no text editor available
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@59c99c507238:/workdir/docker-dbg$ devtool edit-recipe ifupdown /bin/sh: 1: vi: not found ERROR: Execution of 'vi' failed: Command 'vi "/workdir/docker-dbg/workspace/recipes/ifupdown/ifupdown_0.8.16.bb"' returned non-zero exit status 127 [YOCTO #11434] (From OE-Core rev: c536ccfd162fc8871838fa229012c562e3f8e0d9) Signed-off-by: Chang Rebecca Swee Fun <rebecca.swee.fun.chang@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/scriptutils.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py
index 1005dd495a..b6217dc059 100644
--- a/scripts/lib/scriptutils.py
+++ b/scripts/lib/scriptutils.py
@@ -216,8 +216,8 @@ def run_editor(fn):
216 editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi')) 216 editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi'))
217 try: 217 try:
218 return subprocess.check_call('%s %s' % (editor, params), shell=True) 218 return subprocess.check_call('%s %s' % (editor, params), shell=True)
219 except OSError as exc: 219 except subprocess.CalledProcessError as exc:
220 logger.error("Execution of editor '%s' failed: %s", editor, exc) 220 logger.error("Execution of '%s' failed: %s" % (editor, exc))
221 return 1 221 return 1
222 222
223def is_src_url(param): 223def is_src_url(param):