Isolate util/editor

This commit is contained in:
Douglas Jacobsen 2023-10-12 14:23:53 -06:00
parent 736c46e22d
commit 3a6ad72ac1
6 changed files with 12 additions and 8 deletions

View File

@ -11,6 +11,7 @@
from llnl.util import tty
import spack.cmd
import spack.config
import spack.repo
import spack.spec
import spack.stage
@ -275,4 +276,4 @@ def add_versions_to_package(pkg: PackageBase, version_lines: str):
tty.msg(f"Open {filename} to review the additions.")
if sys.stdout.isatty():
editor(filename)
editor(filename, debug=spack.config.get('config:debug'))

View File

@ -180,7 +180,7 @@ def config_edit(args):
if args.print_file:
print(config_file)
else:
editor(config_file)
editor(config_file, debug=spack.config.get('config:debug'))
def config_list(args):

View File

@ -11,6 +11,7 @@
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp
import spack.config
import spack.repo
import spack.stage
import spack.util.web
@ -986,4 +987,4 @@ def create(parser, args):
# Optionally open up the new package file in your $EDITOR
if not args.skip_editor:
editor(pkg_path)
editor(pkg_path, debug=spack.config.get('config:debug'))

View File

@ -9,6 +9,7 @@
import llnl.util.tty as tty
import spack.cmd
import spack.config
import spack.paths
import spack.repo
from spack.spec import Spec
@ -45,7 +46,7 @@ def edit_package(name, repo_path, namespace):
else:
raise spack.repo.UnknownPackageError(spec.name)
editor(path)
editor(path, debug=spack.config.get('config:debug'))
def setup_parser(subparser):

View File

@ -9,6 +9,7 @@
from llnl.util.filesystem import mkdirp
from llnl.util.symlink import symlink
import spack.config
import spack.util.editor as ed
@ -39,7 +40,7 @@ def set_up_license(pkg):
write_license_file(pkg, license_path)
# use spack.util.executable so the editor does not hang on return here
ed.editor(license_path, exec_fn=ed.executable)
ed.editor(license_path, exec_fn=ed.executable, debug=spack.config.get('config:debug'))
else:
# Use already existing license file
tty.msg("Found already existing license %s" % license_path)

View File

@ -18,7 +18,6 @@
import llnl.util.tty as tty
import spack.config
import spack.util.executable
#: editors to try if VISUAL and EDITOR are not set
@ -61,7 +60,8 @@ def executable(exe: str, args: List[str]) -> int:
return cmd.returncode
def editor(*args: str, exec_fn: Callable[[str, List[str]], int] = os.execv) -> bool:
def editor(*args: str, exec_fn: Callable[[str, List[str]], int] = os.execv,
debug: bool = False) -> bool:
"""Invoke the user's editor.
This will try to execute the following, in order:
@ -100,7 +100,7 @@ def try_exec(exe, args, var=None):
return exec_fn(exe, args) == 0
except (OSError, spack.util.executable.ProcessError) as e:
if spack.config.get("config:debug"):
if debug:
raise
# Show variable we were trying to use, if it's from one