mirror of
https://git.yoctoproject.org/poky
synced 2026-04-18 03:32:13 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
dd35f69340
commit
e54f9c159d
@@ -20,6 +20,7 @@ import os
|
||||
import logging
|
||||
import glob
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
def logger_create(name):
|
||||
logger = logging.getLogger(name)
|
||||
@@ -101,3 +102,17 @@ def fetch_uri(d, uri, destdir, srcrev=None):
|
||||
os.chdir(olddir)
|
||||
return ret
|
||||
|
||||
def run_editor(fn):
|
||||
if isinstance(fn, basestring):
|
||||
params = '"%s"' % fn
|
||||
else:
|
||||
params = ''
|
||||
for fnitem in fn:
|
||||
params += ' "%s"' % fnitem
|
||||
|
||||
editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi'))
|
||||
try:
|
||||
return subprocess.check_call('%s %s' % (editor, params), shell=True)
|
||||
except OSError as exc:
|
||||
logger.error("Execution of editor '%s' failed: %s", editor, exc)
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user