diff --git a/airlock_libs/Cargo.lock b/airlock_libs/Cargo.lock index 0f8f279..bc4c86f 100644 --- a/airlock_libs/Cargo.lock +++ b/airlock_libs/Cargo.lock @@ -26,7 +26,7 @@ dependencies = [ [[package]] name = "airlock_libs" -version = "4.0.1" +version = "4.0.2" dependencies = [ "chrono", "indicatif", diff --git a/airlock_libs/Cargo.toml b/airlock_libs/Cargo.toml index 85be7cd..957f0fe 100644 --- a/airlock_libs/Cargo.toml +++ b/airlock_libs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "airlock_libs" -version = "4.0.1" +version = "4.0.2" edition = "2024" [lib] diff --git a/airlock_libs/pyproject.toml b/airlock_libs/pyproject.toml index 040ddb0..f5cdea9 100644 --- a/airlock_libs/pyproject.toml +++ b/airlock_libs/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "airlock_libs" -version = "4.0.1" +version = "4.0.2" description = "Airlock Digital API Wrapper" readme = "README.md" license = { text = "AGPL-3.0-only" } diff --git a/airlock_libs/src/services.rs b/airlock_libs/src/services.rs index db1aa60..b437639 100644 --- a/airlock_libs/src/services.rs +++ b/airlock_libs/src/services.rs @@ -96,7 +96,13 @@ pub fn pull_policy_exec_histories( exec_types: String, days: i64, ) -> Py { - let rt = tokio::runtime::Runtime::new().unwrap(); + let rt = match tokio::runtime::Runtime::new() { + Ok(rt) => rt, + Err(e) => { + println!("Failed to build Tokio Runtime: {:?}", e); + std::process::abort(); + } + }; rt.block_on(async { let _ = init_tracer(); }); @@ -135,7 +141,13 @@ pub fn pull_policy_exec_histories( }, }; let data_write = serde_json::to_string_pretty(&data).expect("Failed to serialize"); - fs::write(writeable_filepath.clone(), data_write).unwrap(); + match fs::write(writeable_filepath.clone(), data_write) { + Ok(_) => {} + Err(e) => { + println!("Failed to write to: {:?}: {}", &writeable_filepath, e); + std::process::abort(); + } + } let mut checkpoint_number: String = skipback(days).to_string(); let multi_progress = MultiProgress::new(); multi_progress.set_draw_target(ProgressDrawTarget::stdout()); @@ -274,7 +286,12 @@ pub fn pull_policy_exec_histories( }, }; let data_write = serde_json::to_string_pretty(&final_response).unwrap(); - fs::write(&writeable_filepath, data_write).unwrap(); + match fs::write(&writeable_filepath, data_write) { + Ok(_) => {} + Err(e) => { + println!("Failed to write to: {:?}: {}", &writeable_filepath, e); + } + } if let Some(last_item) = &final_response.response.exechistories.last() && let Ok(last_date) = NaiveDate::parse_from_str( &last_item.datetime.replace(" +0000 UTC", ""), @@ -289,7 +306,13 @@ pub fn pull_policy_exec_histories( } }); progress_bar.finish_with_message("All Checkpoints Complete"); - let return_data = fs::read_to_string(&writeable_filepath).unwrap(); + let return_data = match fs::read_to_string(&writeable_filepath) { + Ok(return_data) => return_data, + Err(e) => { + println!("Failed to read data from: {:?}: {}", &writeable_filepath, e); + std::process::abort(); + } + }; shutdown_tracer_provider(); PyString::new(py, &return_data).into() } diff --git a/requirements.txt b/requirements.txt index c88d6c0..e3c292a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,4 @@ urllib3==2.5.0 pyperclip==1.11.0 --extra-index-url https://git.racooncity.org/api/packages/brotoskyj/pypi/simple/ -airlock_libs==4.0.1 \ No newline at end of file +airlock_libs==4.0.2 \ No newline at end of file