import logging
import argparse
import subprocess
+import scriptutils
from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, DevtoolError
from devtool import parse_recipe
raise DevtoolError("Recipe file for %s is not under the workspace" %
args.recipename)
- editor = os.environ.get('EDITOR', None)
- if not editor:
- raise DevtoolError("EDITOR environment variable not set")
-
- import subprocess
- try:
- subprocess.check_call('%s "%s"' % (editor, recipefile), shell=True)
- except subprocess.CalledProcessError as e:
- return e.returncode
-
- return 0
+ return scriptutils.run_editor(recipefile)
def configure_help(args, config, basepath, workspace):
import re
import subprocess
import sys
+import scriptutils
logger = logging.getLogger('recipetool')
return 1
if args.edit:
- editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi'))
- try:
- return subprocess.check_call([editor, append_path, recipe_path])
- except OSError as exc:
- logger.error("Execution of editor '%s' failed: %s", editor, exc)
- return 1
+ return scriptutils.run_editor([append_path, recipe_path])
else:
print(append_path)
import logging
import glob
import argparse
+import subprocess
def logger_create(name):
logger = logging.getLogger(name)
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