summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClementTsang <clementjhtsang@gmail.com>2020-01-06 23:07:58 -0500
committerClementTsang <clementjhtsang@gmail.com>2020-01-06 23:07:58 -0500
commitad190a144d54049297d34807baba0e5c3c903503 (patch)
tree7f11f77b33d21bdb31b9b2558abcf06ee37648b6
parente71e22f726422634c986920021faccb94546b1fc (diff)
Some basic cleaning
-rw-r--r--Cargo.toml2
-rw-r--r--src/app/data_collection/processes.rs16
-rw-r--r--src/app/process_killer.rs3
-rw-r--r--src/canvas.rs5
4 files changed, 19 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index c5a466d0..8496d4ad 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bottom"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Clement Tsang <clementjhtsang@gmail.com>"]
edition = "2018"
repository = "https://github.com/ClementTsang/bottom"
diff --git a/src/app/data_collection/processes.rs b/src/app/data_collection/processes.rs
index 16e612c1..a8916a8e 100644
--- a/src/app/data_collection/processes.rs
+++ b/src/app/data_collection/processes.rs
@@ -34,10 +34,20 @@ fn cpu_usage_calculation(prev_idle: &mut f64, prev_non_idle: &mut f64) -> error:
path.push("stat");
let stat_results = std::fs::read_to_string(path)?;
- let first_line = stat_results.split('\n').collect::<Vec<&str>>()[0];
+ let first_line: &str;
+
+ let split_results = stat_results.split('\n').collect::<Vec<&str>>();
+ if split_results.is_empty() {
+ return Err(error::BottomError::InvalidIO {
+ message: format!(
+ "Unable to properly split the stat results; saw {} values, expected at least 1 value.",
+ split_results.len()
+ ),
+ });
+ } else {
+ first_line = split_results[0];
+ }
- // TODO: Consider grabbing by number of threads instead, and summing the total?
- // ie: 4 threads, so: (prev - cur) / cpu_0 + ... + (prev - cur) / cpu_n instead? This might be how top does it?
let val = first_line.split_whitespace().collect::<Vec<&str>>();
// SC in case that the parsing will fail due to length:
diff --git a/src/app/process_killer.rs b/src/app/process_killer.rs
index 1c4e5117..fe058bb9 100644
--- a/src/app/process_killer.rs
+++ b/src/app/process_killer.rs
@@ -47,9 +47,8 @@ pub fn kill_process_given_pid(pid: u32) -> crate::utils::error::Result<()> {
message: "Sorry, macOS support is not implemented yet!".to_string(),
});
} else {
- // TODO: Others?
return Err(BottomError::GenericError {
- message: "Sorry, support operating systems outside the main three is not implemented yet!".to_string(),
+ message: "Sorry, support operating systems outside the main three are not implemented yet!".to_string(),
});
}
diff --git a/src/canvas.rs b/src/canvas.rs
index 09f84438..26a9896c 100644
--- a/src/canvas.rs
+++ b/src/canvas.rs
@@ -373,6 +373,10 @@ fn draw_cpu_legend<B: backend::Backend>(f: &mut Frame<B>, app_state: &mut app::A
.render(f, draw_loc);
}
+fn _draw_memory_table<B: backend::Backend>(_f: &mut Frame<B>, _app_state: &app::App, _draw_loc: Rect) {
+ todo!("Not implemented yet..."); // TODO: For basic mode
+}
+
fn draw_memory_graph<B: backend::Backend>(f: &mut Frame<B>, app_state: &app::App, draw_loc: Rect) {
let mem_data: &[(f64, f64)] = &(app_state.canvas_data.mem_data);
let swap_data: &[(f64, f64)] = &(app_state.canvas_data.swap_data);
@@ -598,7 +602,6 @@ fn draw_disk_table<B: backend::Backend>(f: &mut Frame<B>, app_state: &mut app::A
)
});
- // TODO: We may have to dynamically remove some of these table elements based on size...
Table::new(["Disk", "Mount", "Used", "Total", "Free", "R/s", "W/s"].iter(), disk_rows)
.block(
Block::default()