diff --git a/mitmproxy-linux/build.rs b/mitmproxy-linux/build.rs index 23de726b..07e1883d 100644 --- a/mitmproxy-linux/build.rs +++ b/mitmproxy-linux/build.rs @@ -86,7 +86,16 @@ fn main() { let stderr = std::thread::spawn(move || { for line in stderr.lines() { let line = line.unwrap(); - let skip = line.contains("Compiling ") || line.contains("Finished `"); + let skip = line.contains("info: latest update on") + || line.contains("syncing channel updates") + || line.contains("downloading component") + || line.contains("installing component") + || line.contains("Updating crates.io index") + || line.contains("Updating git repository") + || line.contains("Downloading") + || line.contains("Downloaded") + || line.contains("Compiling ") + || line.contains("Finished `"); if !skip { println!("cargo:warning={line}"); } diff --git a/mitmproxy-rs/src/process_info.rs b/mitmproxy-rs/src/process_info.rs index a8747034..d90775ca 100644 --- a/mitmproxy-rs/src/process_info.rs +++ b/mitmproxy-rs/src/process_info.rs @@ -1,7 +1,10 @@ use std::path::{Path, PathBuf}; -use anyhow::Result; +#[cfg(any(windows, target_os = "macos"))] +use anyhow::Context; use pyo3::prelude::*; +#[cfg(any(windows, target_os = "macos"))] +use pyo3::IntoPyObjectExt; #[cfg(any(windows, target_os = "macos", target_os = "linux"))] use mitmproxy::processes; @@ -67,18 +70,17 @@ pub fn active_executables() -> PyResult> { /// *Availability: Windows, macOS* #[pyfunction] #[allow(unused_variables)] -pub fn executable_icon(path: PathBuf) -> Result { +pub fn executable_icon(py: Python<'_>, path: PathBuf) -> PyResult { #[cfg(any(windows, target_os = "macos"))] { let mut icon_cache = processes::ICON_CACHE.lock().unwrap(); - let png_bytes = icon_cache.get_png(path)?; - Ok(Python::with_gil(|py| { - pyo3::types::PyBytes::new(py, png_bytes).to_object(py) - })) + icon_cache + .get_png(path) + .context("failed to get image")? + .into_py_any(py) } #[cfg(not(any(windows, target_os = "macos")))] Err(pyo3::exceptions::PyNotImplementedError::new_err( "executable_icon is only available on Windows", - ) - .into()) + )) }