use Excecutable instead of exec for editing licenses (#11968)
* fix defunct editor exit in #11691
This commit is contained in:
		 Gregory Lee
					Gregory Lee
				
			
				
					committed by
					
						 Todd Gamblin
						Todd Gamblin
					
				
			
			
				
	
			
			
			 Todd Gamblin
						Todd Gamblin
					
				
			
						parent
						
							fff99a8a3a
						
					
				
				
					commit
					e8a71089a6
				
			| @@ -9,6 +9,7 @@ | ||||
| from llnl.util.filesystem import mkdirp | ||||
|  | ||||
| from spack.util.editor import editor | ||||
| from spack.util.executable import Executable, which | ||||
|  | ||||
|  | ||||
| def pre_install(spec): | ||||
| @@ -37,8 +38,26 @@ def set_up_license(pkg): | ||||
|             # Create a new license file | ||||
|             write_license_file(pkg, license_path) | ||||
|             # Open up file in user's favorite $EDITOR for editing | ||||
|             editor(license_path) | ||||
|             tty.msg("Added global license file %s" % license_path) | ||||
|             editor_exe = None | ||||
|             if 'VISUAL' in os.environ: | ||||
|                 editor_exe = Executable(os.environ['VISUAL']) | ||||
|                 # gvim runs in the background by default so we force it to run | ||||
|                 # in the foreground to make sure the license file is updated | ||||
|                 # before we try to install | ||||
|                 if 'gvim' in os.environ['VISUAL']: | ||||
|                     editor_exe.add_default_arg('-f') | ||||
|             elif 'EDITOR' in os.environ: | ||||
|                 editor_exe = Executable(os.environ['EDITOR']) | ||||
|             else: | ||||
|                 editor_exe = which('vim', 'vi', 'emacs', 'nano') | ||||
|             if editor_exe is None: | ||||
|                 raise EnvironmentError( | ||||
|                     'No text editor found! Please set the VISUAL and/or EDITOR' | ||||
|                     ' environment variable(s) to your preferred text editor.') | ||||
|  | ||||
|             def editor_wrapper(exe, args): | ||||
|                 editor_exe(license_path) | ||||
|             editor(license_path, _exec_func=editor_wrapper) | ||||
|         else: | ||||
|             # Use already existing license file | ||||
|             tty.msg("Found already existing license %s" % license_path) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user