mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
update some dependencies (#6009)
* update some dependencies * there may be some bugs here but it seems to compile and run * clippy
This commit is contained in:
@ -52,7 +52,7 @@ is-root = "0.1.2"
|
||||
itertools = "0.10.0"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.14"
|
||||
lscolors = { version = "0.9.0", features = ["crossterm"]}
|
||||
lscolors = { version = "0.10.0", features = ["crossterm"]}
|
||||
md5 = { package = "md-5", version = "0.10.0" }
|
||||
meval = "0.2.0"
|
||||
mime = "0.3.16"
|
||||
@ -60,7 +60,7 @@ notify = "4.0.17"
|
||||
num = { version = "0.4.0", optional = true }
|
||||
pathdiff = "0.2.1"
|
||||
powierza-coefficient = "1.0"
|
||||
quick-xml = "0.22"
|
||||
quick-xml = "0.23.0"
|
||||
rand = "0.8"
|
||||
rayon = "1.5.1"
|
||||
regex = "1.5.4"
|
||||
@ -73,19 +73,19 @@ serde_urlencoded = "0.7.0"
|
||||
serde_yaml = "0.8.16"
|
||||
sha2 = "0.10.0"
|
||||
# Disable default features b/c the default features build Git (very slow to compile)
|
||||
shadow-rs = { version = "0.11.0", default-features = false }
|
||||
shadow-rs = { version = "0.12.0", default-features = false }
|
||||
strip-ansi-escapes = "0.1.1"
|
||||
sysinfo = "0.23.5"
|
||||
terminal_size = "0.1.17"
|
||||
sysinfo = "0.24.6"
|
||||
terminal_size = "0.2.1"
|
||||
thiserror = "1.0.31"
|
||||
titlecase = "1.1.0"
|
||||
titlecase = "2.0.0"
|
||||
toml = "0.5.8"
|
||||
unicode-segmentation = "1.8.0"
|
||||
url = "2.2.1"
|
||||
uuid = { version = "0.8.2", features = ["v4"] }
|
||||
uuid = { version = "1.1.2", features = ["v4"] }
|
||||
which = { version = "4.2.2", optional = true }
|
||||
reedline = { version = "0.8.0", features = ["bashisms", "sqlite"]}
|
||||
wax = { version = "0.4.0", features = ["diagnostics"] }
|
||||
wax = { version = "0.5.0", features = ["diagnostics"] }
|
||||
rusqlite = { version = "0.27.0", features = ["bundled"], optional = true }
|
||||
sqlparser = { version = "0.16.0", features = ["serde"], optional = true }
|
||||
|
||||
@ -126,11 +126,11 @@ dataframe = ["polars", "num"]
|
||||
database = ["sqlparser", "rusqlite"]
|
||||
|
||||
[build-dependencies]
|
||||
shadow-rs = { version = "0.11.0", default-features = false }
|
||||
shadow-rs = { version = "0.12.0", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
hamcrest2 = "0.3.0"
|
||||
dirs-next = "2.0.0"
|
||||
quickcheck = "1.0.3"
|
||||
quickcheck_macros = "1.0.0"
|
||||
rstest = "0.12.0"
|
||||
rstest = "0.15.0"
|
||||
|
@ -6,7 +6,7 @@ use nu_protocol::{
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Spanned,
|
||||
SyntaxShape, Value,
|
||||
};
|
||||
use wax::Glob as WaxGlob;
|
||||
use wax::{Glob as WaxGlob, WalkBehavior};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Glob;
|
||||
@ -120,7 +120,13 @@ impl Command for Glob {
|
||||
|
||||
#[allow(clippy::needless_collect)]
|
||||
let glob_results: Vec<Value> = glob
|
||||
.walk(path, folder_depth)
|
||||
.walk_with_behavior(
|
||||
path,
|
||||
WalkBehavior {
|
||||
depth: folder_depth,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.flatten()
|
||||
.map(|entry| Value::String {
|
||||
val: entry.into_path().to_string_lossy().to_string(),
|
||||
|
@ -40,7 +40,7 @@ impl Command for SubCommand {
|
||||
|
||||
fn uuid(call: &Call) -> Result<PipelineData, ShellError> {
|
||||
let span = call.head;
|
||||
let uuid_4 = Uuid::new_v4().to_hyphenated().to_string();
|
||||
let uuid_4 = Uuid::new_v4().hyphenated().to_string();
|
||||
|
||||
Ok(PipelineData::Value(
|
||||
Value::String { val: uuid_4, span },
|
||||
|
@ -6,7 +6,7 @@ use nu_protocol::{
|
||||
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Value,
|
||||
};
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
use sysinfo::{ComponentExt, DiskExt, NetworkExt, ProcessorExt, System, SystemExt, UserExt};
|
||||
use sysinfo::{ComponentExt, CpuExt, DiskExt, NetworkExt, System, SystemExt, UserExt};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Sys;
|
||||
@ -199,7 +199,7 @@ pub fn cpu(sys: &mut System, span: Span) -> Option<Value> {
|
||||
sys.refresh_cpu();
|
||||
|
||||
let mut output = vec![];
|
||||
for cpu in sys.processors() {
|
||||
for cpu in sys.cpus() {
|
||||
let mut cols = vec![];
|
||||
let mut vals = vec![];
|
||||
|
||||
|
@ -13,7 +13,7 @@ nu-glob = { path = "../nu-glob", version = "0.65.1" }
|
||||
nu-utils = { path = "../nu-utils", version = "0.65.1" }
|
||||
|
||||
chrono = { version="0.4.19", features=["serde"] }
|
||||
sysinfo = "0.23.10"
|
||||
sysinfo = "0.24.6"
|
||||
|
||||
[features]
|
||||
plugin = []
|
||||
|
@ -19,7 +19,7 @@ chrono-humanize = "0.2.1"
|
||||
byte-unit = "4.0.9"
|
||||
serde_json = { version = "1.0", optional = true }
|
||||
nu-json = { path = "../nu-json", version = "0.65.1" }
|
||||
typetag = "0.1.8"
|
||||
typetag = "0.2.1"
|
||||
num-format = "0.4.0"
|
||||
sys-locale = "0.2.0"
|
||||
regex = "1.5.4"
|
||||
|
@ -16,10 +16,10 @@ path = "src/main.rs"
|
||||
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
||||
procfs = "0.12.0"
|
||||
procfs = "0.13.0"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
libproc = "0.10"
|
||||
libproc = "0.12.0"
|
||||
errno = "0.2"
|
||||
libc = "0.2"
|
||||
|
||||
|
@ -6,14 +6,17 @@ use std::time::{Duration, Instant};
|
||||
|
||||
pub enum ProcessTask {
|
||||
Process(Process),
|
||||
Task { stat: Stat, owner: u32 },
|
||||
Task { stat: Box<Stat>, owner: u32 },
|
||||
}
|
||||
|
||||
impl ProcessTask {
|
||||
pub fn stat(&self) -> &Stat {
|
||||
pub fn stat(&self) -> Result<Stat, ProcError> {
|
||||
match self {
|
||||
ProcessTask::Process(x) => &x.stat,
|
||||
ProcessTask::Task { stat: x, owner: _ } => x,
|
||||
ProcessTask::Process(x) => match x.stat() {
|
||||
Ok(it) => Ok(it),
|
||||
Err(err) => Err(err),
|
||||
},
|
||||
ProcessTask::Task { stat: x, owner: _ } => Ok(*x.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +36,13 @@ impl ProcessTask {
|
||||
|
||||
pub fn fd(&self) -> Result<Vec<FDInfo>, ProcError> {
|
||||
match self {
|
||||
ProcessTask::Process(x) => x.fd(),
|
||||
ProcessTask::Process(x) => {
|
||||
let fds = match x.fd() {
|
||||
Ok(f) => f,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
fds.collect()
|
||||
}
|
||||
_ => Err(ProcError::Other("not supported".to_string())),
|
||||
}
|
||||
}
|
||||
@ -47,7 +56,7 @@ impl ProcessTask {
|
||||
|
||||
pub fn owner(&self) -> u32 {
|
||||
match self {
|
||||
ProcessTask::Process(x) => x.owner,
|
||||
ProcessTask::Process(x) => x.uid().unwrap_or(0),
|
||||
ProcessTask::Task { stat: _, owner: x } => *x,
|
||||
}
|
||||
}
|
||||
@ -77,32 +86,54 @@ pub fn collect_proc(interval: Duration, with_thread: bool) -> Vec<ProcessInfo> {
|
||||
let mut ret = Vec::new();
|
||||
|
||||
if let Ok(all_proc) = procfs::process::all_processes() {
|
||||
for proc in all_proc {
|
||||
for proc in all_proc.flatten() {
|
||||
let io = proc.io().ok();
|
||||
let time = Instant::now();
|
||||
if with_thread {
|
||||
if let Ok(iter) = proc.tasks() {
|
||||
collect_task(iter, &mut base_tasks);
|
||||
}
|
||||
base_procs.push((proc.pid(), proc, io, time));
|
||||
}
|
||||
base_procs.push((proc.pid(), proc, io, time));
|
||||
// match proc {
|
||||
// Ok(p) => {
|
||||
// let io = p.io().ok();
|
||||
// let time = Instant::now();
|
||||
// if with_thread {
|
||||
// if let Ok(iter) = p.tasks() {
|
||||
// collect_task(iter, &mut base_tasks);
|
||||
// }
|
||||
// }
|
||||
// base_procs.push((p.pid(), p, io, time));
|
||||
// }
|
||||
// Err(_) => {}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
thread::sleep(interval);
|
||||
|
||||
for (pid, prev_proc, prev_io, prev_time) in base_procs {
|
||||
let curr_proc = if let Ok(proc) = Process::new(pid) {
|
||||
proc
|
||||
} else {
|
||||
prev_proc.clone()
|
||||
let curr_proc_pid = pid;
|
||||
let prev_proc_pid = prev_proc.pid();
|
||||
let curr_proc = match Process::new(curr_proc_pid) {
|
||||
Ok(p) => p,
|
||||
Err(_) => return Vec::<ProcessInfo>::new(),
|
||||
};
|
||||
let prev_proc = match Process::new(prev_proc_pid) {
|
||||
Ok(p) => p,
|
||||
Err(_) => return Vec::<ProcessInfo>::new(),
|
||||
};
|
||||
|
||||
let curr_io = curr_proc.io().ok();
|
||||
let curr_status = curr_proc.status().ok();
|
||||
let curr_time = Instant::now();
|
||||
let interval = curr_time - prev_time;
|
||||
let ppid = curr_proc.stat.ppid;
|
||||
let owner = curr_proc.owner;
|
||||
let ppid = match curr_proc.stat() {
|
||||
Ok(p) => p.ppid,
|
||||
Err(_) => 0,
|
||||
};
|
||||
let owner = curr_proc.uid().unwrap_or(0);
|
||||
|
||||
let mut curr_tasks = HashMap::new();
|
||||
if with_thread {
|
||||
@ -133,11 +164,11 @@ pub fn collect_proc(interval: Duration, with_thread: bool) -> Vec<ProcessInfo> {
|
||||
pid: tid,
|
||||
ppid: pid,
|
||||
curr_proc: ProcessTask::Task {
|
||||
stat: curr_stat,
|
||||
stat: Box::new(curr_stat),
|
||||
owner,
|
||||
},
|
||||
prev_proc: ProcessTask::Task {
|
||||
stat: prev_stat,
|
||||
stat: Box::new(prev_stat),
|
||||
owner,
|
||||
},
|
||||
curr_io,
|
||||
@ -196,35 +227,50 @@ impl ProcessInfo {
|
||||
if !cmd.is_empty() {
|
||||
cmd.join(" ").replace('\n', " ").replace('\t', " ")
|
||||
} else {
|
||||
self.curr_proc.stat().comm.clone()
|
||||
match self.curr_proc.stat() {
|
||||
Ok(p) => p.comm,
|
||||
Err(_) => "".to_string(),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.curr_proc.stat().comm.clone()
|
||||
match self.curr_proc.stat() {
|
||||
Ok(p) => p.comm,
|
||||
Err(_) => "".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the status of the process
|
||||
pub fn status(&self) -> String {
|
||||
match self.curr_proc.stat().state {
|
||||
'S' => "Sleeping".into(),
|
||||
'R' => "Running".into(),
|
||||
'D' => "Disk sleep".into(),
|
||||
'Z' => "Zombie".into(),
|
||||
'T' => "Stopped".into(),
|
||||
't' => "Tracing".into(),
|
||||
'X' => "Dead".into(),
|
||||
'x' => "Dead".into(),
|
||||
'K' => "Wakekill".into(),
|
||||
'W' => "Waking".into(),
|
||||
'P' => "Parked".into(),
|
||||
_ => "Unknown".into(),
|
||||
match self.curr_proc.stat() {
|
||||
Ok(p) => match p.state {
|
||||
'S' => "Sleeping".into(),
|
||||
'R' => "Running".into(),
|
||||
'D' => "Disk sleep".into(),
|
||||
'Z' => "Zombie".into(),
|
||||
'T' => "Stopped".into(),
|
||||
't' => "Tracing".into(),
|
||||
'X' => "Dead".into(),
|
||||
'x' => "Dead".into(),
|
||||
'K' => "Wakekill".into(),
|
||||
'W' => "Waking".into(),
|
||||
'P' => "Parked".into(),
|
||||
_ => "Unknown".into(),
|
||||
},
|
||||
Err(_) => "Unknown".into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// CPU usage as a percent of total
|
||||
pub fn cpu_usage(&self) -> f64 {
|
||||
let curr_time = self.curr_proc.stat().utime + self.curr_proc.stat().stime;
|
||||
let prev_time = self.prev_proc.stat().utime + self.prev_proc.stat().stime;
|
||||
let curr_time = match self.curr_proc.stat() {
|
||||
Ok(c) => c.utime + c.stime,
|
||||
Err(_) => 0,
|
||||
};
|
||||
let prev_time = match self.prev_proc.stat() {
|
||||
Ok(c) => c.utime + c.stime,
|
||||
Err(_) => 0,
|
||||
};
|
||||
let usage_ms =
|
||||
(curr_time - prev_time) * 1000 / procfs::ticks_per_second().unwrap_or(100) as u64;
|
||||
let interval_ms = self.interval.as_secs() * 1000 + u64::from(self.interval.subsec_millis());
|
||||
@ -233,11 +279,17 @@ impl ProcessInfo {
|
||||
|
||||
/// Memory size in number of bytes
|
||||
pub fn mem_size(&self) -> u64 {
|
||||
self.curr_proc.stat().rss_bytes().unwrap_or(0) as u64
|
||||
match self.curr_proc.stat() {
|
||||
Ok(p) => p.rss_bytes().unwrap_or(0),
|
||||
Err(_) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Virtual memory size in bytes
|
||||
pub fn virtual_size(&self) -> u64 {
|
||||
self.curr_proc.stat().vsize
|
||||
match self.curr_proc.stat() {
|
||||
Ok(p) => p.vsize,
|
||||
Err(_) => 0u64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user