Strong error checking in the Python side

This commit is contained in:
Herbert Wolverson committed 2025-05-30 09:46:00 -05:00
1 parent 1338aedcc9
commit f76da3c727
2 files changed
+10 -3

No files matched your search

+1
View File
@@ -124,3 +124,4 @@ src/rust/lqosd/lts_keys.bin
src/rust/lqosd/src/node_manager/js_build/out
src/bin/dashboards
.aider*
src/geo2.bin
+9 -3
View File
@@ -807,12 +807,18 @@ fn insight_topology_role() -> PyResult<String> {
#[pyfunction]
fn calculate_hash() -> PyResult<i64> {
let config = lqos_config::load_config().unwrap();
let Ok(config) = lqos_config::load_config() else {
return Ok(0);
};
let nj_path = Path::new(&config.lqos_directory).join("network.json");
let sd_path = Path::new(&config.lqos_directory).join("ShapedDevices.csv");
let nj_as_string = read_to_string(nj_path)?;
let sd_as_string = read_to_string(sd_path)?;
let Ok(nj_as_string) = read_to_string(nj_path) else {
return Ok(0);
};
let Ok(sd_as_string) = read_to_string(sd_path) else {
return Ok(0);
};
let combined = format!("{}\n{}", nj_as_string, sd_as_string);
let hash = hash_to_i64(&combined);