summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Schlömer <nico.schloemer@gmail.com>2022-03-07 20:20:55 +0100
committerGitHub <noreply@github.com>2022-03-07 20:20:55 +0100
commite6b8fe58b6588437c52de8ee161e5ba384b9c347 (patch)
tree59d23b49c41177326af32fa17ac7f4b2db1a76cc
parentc13ef92b2f7a58ea3cb135a1afce1fe1dd76ccf5 (diff)
parentc6eda0e33d7e84ef42600d3f3cfa890fddcb7fbd (diff)
Merge pull request #74 from nschloe/disk-fixv0.2.2
Disk fix
-rw-r--r--src/tiptop/__about__.py2
-rw-r--r--src/tiptop/_cpu.py7
-rw-r--r--src/tiptop/_disk.py18
3 files changed, 14 insertions, 13 deletions
diff --git a/src/tiptop/__about__.py b/src/tiptop/__about__.py
index 3ced358..b5fdc75 100644
--- a/src/tiptop/__about__.py
+++ b/src/tiptop/__about__.py
@@ -1 +1 @@
-__version__ = "0.2.1"
+__version__ = "0.2.2"
diff --git a/src/tiptop/_cpu.py b/src/tiptop/_cpu.py
index 9cd006b..8b0951c 100644
--- a/src/tiptop/_cpu.py
+++ b/src/tiptop/_cpu.py
@@ -254,7 +254,7 @@ class CPU(Widget):
if self.has_fan_rpm:
fan_current = list(psutil.sensors_fans().values())[0][0].current
- # See command above
+ # See comment above
if fan_current == 65535:
fan_current = self.fan_stream.maxval
@@ -264,8 +264,9 @@ class CPU(Widget):
self.fan_stream.add_value(fan_current)
string = f" {fan_current}rpm"
- graph = (
- "[cyan]" + self.fan_stream.graph[-1][: -len(string)] + string + "[/]"
+ graph = Text(
+ self.fan_stream.graph[-1][: -len(string)] + string,
+ style="cyan",
)
t.add_row(graph, "")
diff --git a/src/tiptop/_disk.py b/src/tiptop/_disk.py
index d428a8e..75fc039 100644
--- a/src/tiptop/_disk.py
+++ b/src/tiptop/_disk.py
@@ -46,10 +46,6 @@ class Disk(Widget):
for item in psutil.disk_partitions()
if not item.device.startswith("/dev/loop")
]
- self.total = [
- sizeof_fmt(psutil.disk_usage(mp).total, fmt=".1f")
- for mp in self.mountpoints
- ]
self.group = Group(self.table, "")
self.panel = Panel(
@@ -128,14 +124,18 @@ class Disk(Widget):
)
table = Table(box=None, expand=False, padding=(0, 1), show_header=True)
- table.add_column("", justify="left", no_wrap=True)
+ table.add_column("", justify="left", no_wrap=True, style="bold")
table.add_column(Text("free", justify="left"), justify="right", no_wrap=True)
table.add_column(Text("used", justify="left"), justify="right", no_wrap=True)
table.add_column(Text("total", justify="left"), justify="right", no_wrap=True)
table.add_column("", justify="right", no_wrap=True)
- for mp, total in zip(self.mountpoints, self.total):
- du = psutil.disk_usage(mp)
+ for mp in self.mountpoints:
+ try:
+ du = psutil.disk_usage(mp)
+ except PermissionError:
+ # https://github.com/nschloe/tiptop/issues/71
+ continue
style = None
if du.percent > 99:
@@ -144,10 +144,10 @@ class Disk(Widget):
style = "yellow"
table.add_row(
- f"[b]{mp}[/]",
+ mp,
sizeof_fmt(du.free, fmt=".1f"),
sizeof_fmt(du.used, fmt=".1f"),
- total,
+ sizeof_fmt(du.total, fmt=".1f"),
f"({du.percent:.1f}%)",
style=style,
)