1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
use expectrl::{repl::spawn_python, Regex};
#[cfg(not(feature = "async"))]
fn main() {
let mut p = spawn_python().unwrap();
p.execute("import platform").unwrap();
p.send_line("platform.node()").unwrap();
let found = p.expect(Regex(r"'.*'")).unwrap();
println!(
"Platform {}",
String::from_utf8_lossy(found.get(0).unwrap())
);
}
#[cfg(feature = "async")]
fn main() {
futures_lite::future::block_on(async {
let mut p = spawn_python().await.unwrap();
p.execute("import platform").await.unwrap();
p.send_line("platform.node()").await.unwrap();
let found = p.expect(Regex(r"'.*'")).await.unwrap();
println!(
"Platform {}",
String::from_utf8_lossy(found.get(0).unwrap())
);
})
}
|