diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-02-19 22:38:50 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-21 09:32:42 +0000 |
commit | e54f9c159d5d9f9f424e1878ad7fedda13201f59 (patch) | |
tree | 078b647539598880a5fb67aa6575744b30ba7a60 /scripts/lib/recipetool | |
parent | dd35f69340c399f54759482fc2865874e2f8ab09 (diff) | |
download | poky-e54f9c159d5d9f9f424e1878ad7fedda13201f59.tar.gz |
devtool / recipetool: use common code for launching editor
Looking at Chris Larson's code for starting the user's editor for
"recipetool newappend" it was slightly better than what I wrote for
"devtool edit-recipe" in that it checks VISUAL as well as EDITOR and
defaults to vi if neither are set, so break this out to its own function
and call it from both places. The broken out version passes shell=True
however in case it's a more complicated command rather than just a name
of an executable.
(From OE-Core rev: 184a256931e8cdc7bea97a905c4e67a435964de0)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/recipetool')
-rw-r--r-- | scripts/lib/recipetool/newappend.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/scripts/lib/recipetool/newappend.py b/scripts/lib/recipetool/newappend.py index 5625a8ed52..bdf0693ec7 100644 --- a/scripts/lib/recipetool/newappend.py +++ b/scripts/lib/recipetool/newappend.py | |||
@@ -27,6 +27,7 @@ import os | |||
27 | import re | 27 | import re |
28 | import subprocess | 28 | import subprocess |
29 | import sys | 29 | import sys |
30 | import scriptutils | ||
30 | 31 | ||
31 | 32 | ||
32 | logger = logging.getLogger('recipetool') | 33 | logger = logging.getLogger('recipetool') |
@@ -96,12 +97,7 @@ def newappend(args): | |||
96 | return 1 | 97 | return 1 |
97 | 98 | ||
98 | if args.edit: | 99 | if args.edit: |
99 | editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi')) | 100 | return scriptutils.run_editor([append_path, recipe_path]) |
100 | try: | ||
101 | return subprocess.check_call([editor, append_path, recipe_path]) | ||
102 | except OSError as exc: | ||
103 | logger.error("Execution of editor '%s' failed: %s", editor, exc) | ||
104 | return 1 | ||
105 | else: | 101 | else: |
106 | print(append_path) | 102 | print(append_path) |
107 | 103 | ||