Let the shell component write out stderr and stdout if names are given

This commit is contained in:
Joshua Harlow
2012-06-05 11:00:31 -07:00
parent 1eab5cb8e8
commit 03ec513bad
2 changed files with 25 additions and 18 deletions

View File

@@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import re
import weakref
@@ -323,18 +322,14 @@ class PythonInstallComponent(PkgInstallComponent):
for (name, working_dir) in real_dirs.items():
self.tracewriter.dirs_made(*sh.mkdirslist(working_dir))
self.tracewriter.py_installed(name, working_dir)
(stdout, stderr) = sh.execute(*setup_cmd,
cwd=working_dir,
run_as_root=True)
py_trace_name = "%s.%s" % (name, 'python')
py_writer = tr.TraceWriter(tr.trace_fn(self.get_option('trace_dir'),
py_trace_name), break_if_there=False)
# Format or json encoding isn't really needed here since this is
# more just for information output/lookup if desired.
py_writer.trace("CMD", " ".join(setup_cmd))
py_writer.trace("STDOUT", stdout)
py_writer.trace("STDERR", stderr)
self.tracewriter.file_touched(py_writer.filename())
root_fn = sh.joinpths(self.get_option('trace_dir'), "%s.python.setup" % (name))
sh.execute(*setup_cmd,
cwd=working_dir,
run_as_root=True,
stderr_fn='%s.stderr' % (root_fn),
stdout_fn='%s.stdout' % (root_fn),
trace_writer=self.tracewriter
)
def _python_install(self):
self._install_pips()

View File

@@ -208,16 +208,28 @@ def execute(*cmd, **kwargs):
stderr = ''
if (not ignore_exit_code) and (rc not in check_exit_code):
raise excp.ProcessExecutionError(exit_code=rc, stdout=stdout, \
raise excp.ProcessExecutionError(exit_code=rc, stdout=stdout,
stderr=stderr, cmd=str_cmd)
else:
# Log it anyway
if rc not in check_exit_code:
LOG.debug("A failure may of just happened when running command %r [%s] (%s, %s)", \
str_cmd, rc, stdout.strip(), stderr.strip())
LOG.debug("A failure may of just happened when running command %r [%s] (%s, %s)",
str_cmd, rc, stdout, stderr)
# Log for debugging figuring stuff out
LOG.debug("Received stdout: %s" % (stdout.strip()))
LOG.debug("Received stderr: %s" % (stderr.strip()))
LOG.debug("Received stdout: %s" % (stdout))
LOG.debug("Received stderr: %s" % (stderr))
# See if a requested storage place was given for stderr/stdout
trace_writer = kwargs.get('trace_writer')
stdout_fn = kwargs.get('stdout_fn')
if stdout_fn:
write_file(stdout_fn, stdout)
if trace_writer:
trace_writer.file_touched(stdout_fn)
stderr_fn = kwargs.get('stderr_fn')
if stderr_fn:
write_file(stderr_fn, stderr)
if trace_writer:
trace_writer.file_touched(stderr_fn)
return (stdout, stderr)