Skip to content

Commit

Permalink
fixed disk view
Browse files Browse the repository at this point in the history
  • Loading branch information
anistark committed Dec 13, 2024
1 parent fb0e1d7 commit 8181670
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://github.com/anistark/sot"><img alt="tiptop" src="./images/sot.png" width="200px"/></a>
<p align="center">Command-line system oberving tool.</p>
<p align="center" style="background-color: #ffffff;">
<a href="https://github.com/anistark/sot"><img alt="sot" src="./images/sot.png" width="200px"/></a>
<p align="center">Command-line system obervation tool.</p>
</p>

`sot` is a Command-line System Obervation Tool in the spirit of [top](<https://en.wikipedia.org/wiki/Top_(software)>). It displays various interesting system stats and graphs them. Works on all operating systems.
Expand Down
2 changes: 1 addition & 1 deletion src/sot/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime

__version__ = "2.0.1"
__version__ = "2.0.2"
__current_year__ = datetime.now().year
6 changes: 5 additions & 1 deletion src/sot/_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def compose(self):
yield Disk()
yield Net(self.net_interface)

def on_mount(self) -> None:
self.title = "SOT"
self.sub_title = "System Observation Tool"

def __init__(self, net_interface=None):
super().__init__()
self.net_interface = net_interface
Expand All @@ -106,6 +110,6 @@ def _get_version_text():
return "\n".join(
[
f"sot {__version__} [Python {python_version}]",
f"Copyright (c) 2024-{__current_year__} Kumar Anirudha",
f"MIT License © 2024-{__current_year__} Kumar Anirudha",
]
)
18 changes: 6 additions & 12 deletions src/sot/_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,12 @@ def refresh_graphs(self):
)

def refresh_disk_usage(self):
table = Table(box=None, expand=False, padding=(0, 1), show_header=True)
table.add_column("", justify="left", no_wrap=True, style="bold")
table.add_column(Text("Free", justify="right"), justify="right", no_wrap=True)
table.add_column(Text("Used", justify="right"), justify="right", no_wrap=True)
table.add_column(Text("Total", justify="right"), justify="right", no_wrap=True)
table.add_column(Text("🍕", justify="right"), justify="right", no_wrap=True)
table = Table(box=None, show_header=False, expand=True)

for mp in self.mountpoints:
try:
du = psutil.disk_usage(mp)
except PermissionError:
# https://github.com/nschloe/tiptop/issues/71
continue

style = None
Expand All @@ -168,13 +162,13 @@ def refresh_disk_usage(self):
style = "dark_orange"

table.add_row(
mp,
sizeof_fmt(du.free, fmt=".1f"),
sizeof_fmt(du.used, fmt=".1f"),
sizeof_fmt(du.total, fmt=".1f"),
f"{du.percent:.1f}%",
f"[b]Free:[/] {sizeof_fmt(du.free, fmt=".1f")}",
f"[b]Used:[/] {sizeof_fmt(du.used, fmt=".1f")}",
f"[b]Total:[/] {sizeof_fmt(du.total, fmt=".1f")}",
f"[b]🍕[/] {du.percent:.1f}%",
style=style,
)

self.group.renderables[-1] = table

def render(self):
Expand Down

0 comments on commit 8181670

Please sign in to comment.