mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +03:00
- Echo process output to the main UI's stdout, for easier debugging - Remove the timing breakdown from elevation import, since it breaks when the function bails out early
This commit is contained in:
parent
272589bbbc
commit
462baddf17
@ -4,20 +4,14 @@ use std::process::Command;
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use abstutil::Timer;
|
|
||||||
use geom::{Distance, PolyLine};
|
use geom::{Distance, PolyLine};
|
||||||
use map_model::raw::{OriginalRoad, RawMap};
|
use map_model::raw::{OriginalRoad, RawMap};
|
||||||
|
|
||||||
pub fn add_data(map: &mut RawMap, timer: &mut Timer) -> Result<()> {
|
pub fn add_data(map: &mut RawMap) -> Result<()> {
|
||||||
timer.start("add elevation data");
|
// TODO It'd be nice to include more timing breakdown here, but if we bail out early,
|
||||||
|
// it's tedious to call timer.stop().
|
||||||
// TODO General problem: If we bail out early, the timer gets screwed up and later crashes. I
|
|
||||||
// think we need to start using scoped objects that call timer.stop() when dropped.
|
|
||||||
timer.start("generate input");
|
|
||||||
let ids = generate_input(map)?;
|
let ids = generate_input(map)?;
|
||||||
timer.stop("generate input");
|
|
||||||
|
|
||||||
timer.start("run elevation_lookups");
|
|
||||||
std::fs::create_dir_all("elevation_output")?;
|
std::fs::create_dir_all("elevation_output")?;
|
||||||
std::fs::create_dir_all(abstio::path_shared_input("elevation"))?;
|
std::fs::create_dir_all(abstio::path_shared_input("elevation"))?;
|
||||||
let pwd = std::env::current_dir()?.display().to_string();
|
let pwd = std::env::current_dir()?.display().to_string();
|
||||||
@ -56,11 +50,8 @@ pub fn add_data(map: &mut RawMap, timer: &mut Timer) -> Result<()> {
|
|||||||
if !status.success() {
|
if !status.success() {
|
||||||
bail!("Command failed: {}", status);
|
bail!("Command failed: {}", status);
|
||||||
}
|
}
|
||||||
timer.stop("run elevation_lookups");
|
|
||||||
|
|
||||||
timer.start("grab output");
|
|
||||||
scrape_output(map, ids)?;
|
scrape_output(map, ids)?;
|
||||||
timer.stop("grab output");
|
|
||||||
|
|
||||||
// Clean up temporary files
|
// Clean up temporary files
|
||||||
std::fs::remove_file("elevation_input/query")?;
|
std::fs::remove_file("elevation_input/query")?;
|
||||||
@ -68,7 +59,6 @@ pub fn add_data(map: &mut RawMap, timer: &mut Timer) -> Result<()> {
|
|||||||
std::fs::remove_file("elevation_output/query")?;
|
std::fs::remove_file("elevation_output/query")?;
|
||||||
std::fs::remove_dir("elevation_output")?;
|
std::fs::remove_dir("elevation_output")?;
|
||||||
|
|
||||||
timer.stop("add elevation data");
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,9 +111,11 @@ pub fn convert(opts: Options, timer: &mut abstutil::Timer) -> RawMap {
|
|||||||
parking::apply_parking(&mut map, &opts, timer);
|
parking::apply_parking(&mut map, &opts, timer);
|
||||||
|
|
||||||
// TODO Make this bail out on failure, after the new dependencies are clearly explained.
|
// TODO Make this bail out on failure, after the new dependencies are clearly explained.
|
||||||
if let Err(err) = elevation::add_data(&mut map, timer) {
|
timer.start("add elevation data");
|
||||||
|
if let Err(err) = elevation::add_data(&mut map) {
|
||||||
error!("No elevation data: {}", err);
|
error!("No elevation data: {}", err);
|
||||||
}
|
}
|
||||||
|
timer.stop("add elevation data");
|
||||||
if let Some(ref path) = opts.extra_buildings {
|
if let Some(ref path) = opts.extra_buildings {
|
||||||
add_extra_buildings(&mut map, path).unwrap();
|
add_extra_buildings(&mut map, path).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ impl<A: AppLike + 'static> RunCommand<A> {
|
|||||||
// This is almost always a timeout.
|
// This is almost always a timeout.
|
||||||
Err(err) => err.capture,
|
Err(err) => err.capture,
|
||||||
};
|
};
|
||||||
|
// TODO This doesn't interleave stdout and stderr as expected.
|
||||||
for raw in vec![stdout, stderr] {
|
for raw in vec![stdout, stderr] {
|
||||||
if let Some(bytes) = raw {
|
if let Some(bytes) = raw {
|
||||||
if let Ok(string) = String::from_utf8(bytes) {
|
if let Ok(string) = String::from_utf8(bytes) {
|
||||||
@ -97,6 +98,7 @@ impl<A: AppLike + 'static> RunCommand<A> {
|
|||||||
self.lines
|
self.lines
|
||||||
.push_back(line.split('\r').last().unwrap().to_string());
|
.push_back(line.split('\r').last().unwrap().to_string());
|
||||||
} else {
|
} else {
|
||||||
|
println!("> {}", line);
|
||||||
self.lines.push_back(line);
|
self.lines.push_back(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user