Properly interleave stdout and stderr when running the importer from the UI, for #602 and #82.

This makes the logs understandable and should fix the issue where the
last line of one_step_import's output is sometimes a warning instead of
the map name.
This commit is contained in:
Dustin Carlino 2021-04-13 10:07:56 -07:00
parent 462baddf17
commit 096acd1fea

View File

@ -37,7 +37,7 @@ impl<A: AppLike + 'static> RunCommand<A> {
&args,
subprocess::PopenConfig {
stdout: subprocess::Redirection::Pipe,
stderr: subprocess::Redirection::Pipe,
stderr: subprocess::Redirection::Merge,
..Default::default()
},
) {
@ -75,14 +75,12 @@ impl<A: AppLike + 'static> RunCommand<A> {
// This is almost always a timeout.
Err(err) => err.capture,
};
// TODO This doesn't interleave stdout and stderr as expected.
for raw in vec![stdout, stderr] {
if let Some(bytes) = raw {
if let Ok(string) = String::from_utf8(bytes) {
if !string.is_empty() {
for line in string.split("\n") {
new_lines.push(line.to_string());
}
assert!(stderr.is_none());
if let Some(bytes) = stdout {
if let Ok(string) = String::from_utf8(bytes) {
if !string.is_empty() {
for line in string.split("\n") {
new_lines.push(line.to_string());
}
}
}