From 6e7ba70def0f8c9b63f0c4c4db922b371317df75 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Mar 2012 16:15:27 -0500 Subject: [PATCH] When a needed shell command is not installed the error message just says "file not found" without showing what file. This change exposes the command line that failed to run and repeats the error message. --- devstack/shell.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/devstack/shell.py b/devstack/shell.py index 47459856..48107a47 100644 --- a/devstack/shell.py +++ b/devstack/shell.py @@ -129,18 +129,21 @@ def execute(*cmd, **kwargs): rc = None result = None with Rooted(run_as_root): - obj = subprocess.Popen(execute_cmd, - stdin=stdin_fh, - stdout=stdout_fh, - stderr=stderr_fh, - close_fds=close_file_descriptors, - cwd=cwd, - shell=shell, - env=process_env) - if process_input is not None: - result = obj.communicate(str(process_input)) - else: - result = obj.communicate() + try: + obj = subprocess.Popen(execute_cmd, + stdin=stdin_fh, + stdout=stdout_fh, + stderr=stderr_fh, + close_fds=close_file_descriptors, + cwd=cwd, + shell=shell, + env=process_env) + if process_input is not None: + result = obj.communicate(str(process_input)) + else: + result = obj.communicate() + except OSError as e: + raise RuntimeError('Could not run %s: %s' % (execute_cmd, e)) if (stdin_fh != subprocess.PIPE and obj.stdin and close_stdin): obj.stdin.close()