Check for more errors when executing subprocess. (#2746)

pull/2754/head
behlec 7 years ago committed by Jussi Pakkanen
parent 8d795a8403
commit 4217a9ca7e
  1. 14
      mesonbuild/scripts/commandrunner.py

@ -31,10 +31,9 @@ def run_command(source_dir, build_dir, subdir, meson_command, command, arguments
exe = shutil.which(command) exe = shutil.which(command)
if exe is not None: if exe is not None:
command_array = [exe] + arguments command_array = [exe] + arguments
return subprocess.Popen(command_array, env=child_env, cwd=cwd) else:# No? Maybe it is a script in the source tree.
# No? Maybe it is a script in the source tree. fullpath = os.path.join(source_dir, subdir, command)
fullpath = os.path.join(source_dir, subdir, command) command_array = [fullpath] + arguments
command_array = [fullpath] + arguments
try: try:
return subprocess.Popen(command_array, env=child_env, cwd=cwd) return subprocess.Popen(command_array, env=child_env, cwd=cwd)
except FileNotFoundError: except FileNotFoundError:
@ -43,6 +42,13 @@ def run_command(source_dir, build_dir, subdir, meson_command, command, arguments
except PermissionError: except PermissionError:
print('Could not execute command "%s". File not executable.' % command) print('Could not execute command "%s". File not executable.' % command)
sys.exit(1) sys.exit(1)
except OSError as err:
print('Could not execute command "{}": {}'.format(command, err))
sys.exit(1)
except subprocess.SubprocessError as err:
print('Could not execute command "{}": {}'.format(command, err))
sys.exit(1)
def run(args): def run(args):
if len(args) < 4: if len(args) < 4:

Loading…
Cancel
Save