Hi I am trying to get my tauri to work with a python script as a sidecar. Reason -> I want to run a python script that uses the users webcam to detect gestures to control the app.
To make it easy, I started with a sample project.
Pyhton script:
import sys
import time
while True:
sys.stdout.write('Hello from python script from stdout')
print("Hello from python script from console")
time.sleep(1)
Converted it to a binary and followed the docs https://tauri.app/v1/guides/building/sidecar/
Src-tauri/main.rs:
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::{
api::process::{Command, CommandEvent}
};
fn main() {
tauri::Builder::default()
.setup(|_app| {
tauri::async_runtime::spawn(async move {
let (mut rx, _child) = Command::new_sidecar("main")
.expect("failed to setup `app` sidecar")
.spawn()
.expect("Failed to spawn packaged node");
while let Some(event) = rx.recv().await {
if let CommandEvent::Stdout(line) = event {
println!("{}", format!("'{}'", line));
}
}
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
I am not getting any error message at all so I assume it runs the sidecar but I am not getting any output from the sidecar. Any reason why?