Formatting Fixes

This commit is contained in:
Sarah Jamie Lewis 2023-01-20 08:07:06 -08:00
parent 122eb8b2ac
commit 7045f99aa6
1 changed files with 8 additions and 3 deletions

View File

@ -14,6 +14,8 @@ pub struct QemuProcess {
len: usize, len: usize,
} }
const DEBUG : bool = false;
/// Pipe streams are blocking, we need separate threads to monitor them without blocking the primary thread. /// Pipe streams are blocking, we need separate threads to monitor them without blocking the primary thread.
fn child_stream_to_vec<R>(stream: R) -> Arc<Mutex<Vec<u8>>> fn child_stream_to_vec<R>(stream: R) -> Arc<Mutex<Vec<u8>>>
where where
@ -121,7 +123,7 @@ impl QemuProcess {
let current_length = stdout.len(); let current_length = stdout.len();
if current_length > last_length { if current_length > last_length {
if output { if DEBUG {
println!("{}", tbd); println!("{}", tbd);
std::io::stdout().flush().expect("could not flush output"); std::io::stdout().flush().expect("could not flush output");
} }
@ -129,6 +131,9 @@ impl QemuProcess {
// Update length // Update length
last_length = current_length; last_length = current_length;
print!(".");
std::io::stdout().flush().expect("could not flush output");
if last.contains("root@debian:") { if last.contains("root@debian:") {
let mut cleaned_lines = vec![]; let mut cleaned_lines = vec![];
println!(". \x1b[1;32mOK\x1b[0m"); println!(". \x1b[1;32mOK\x1b[0m");
@ -205,12 +210,12 @@ impl QemuProcess {
// The output is wrapped in a Result to allow matching on errors // The output is wrapped in a Result to allow matching on errors
// Returns an Iterator to the Reader of the lines of the file. // Returns an Iterator to the Reader of the lines of the file.
fn read_lines<P>(filename: P) -> std::io::Result<std::io::Lines<std::io::BufReader<File>>> fn read_lines<P>(filename: P) -> std::io::Result<std::io::Lines<BufReader<File>>>
where where
P: AsRef<Path>, P: AsRef<Path>,
{ {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(std::io::BufReader::new(file).lines()) Ok(BufReader::new(file).lines())
} }
fn main() { fn main() {