Skip to content

Commit c20da0f

Browse files
committed
initial commit
0 parents  commit c20da0f

30 files changed

+1808
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.codecov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
comment: no

.flake8

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
ignore = E203, E266, E501, W503, E741
3+
max-line-length = 80
4+
max-complexity = 18
5+
select = B,C,E,F,W,T4,B9

.github/renovate.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["config:base"]
3+
}

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.pyc
2+
*.swp
3+
*.prof
4+
MANIFEST
5+
dist/
6+
build/
7+
.coverage
8+
.cache/
9+
*.egg-info/
10+
.pytest_cache/
11+
.tox/
12+
venv
13+
__pycache__

.pre-commit-config.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/PyCQA/isort
3+
rev: 5.10.1
4+
hooks:
5+
- id: isort
6+
7+
- repo: https://github.com/psf/black
8+
rev: 22.8.0
9+
hooks:
10+
- id: black
11+
language_version: python3
12+
13+
- repo: https://github.com/PyCQA/flake8
14+
rev: 5.0.4
15+
hooks:
16+
- id: flake8
17+
18+
- repo: https://github.com/pre-commit/mirrors-prettier
19+
rev: v3.0.0-alpha.0
20+
hooks:
21+
- id: prettier

CONTRIBUTING.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SOT Contributing Guidelines
2+
3+
The SOT community appreciates your contributions via [issues](https://github.com/anistark/sot/pulls) and [pull requests](https://github.com/anistark/sot/pulls).
4+
5+
When submitting pull requests, please follow the style guidelines of the project, ensure that your code is tested and documented, and write good commit messages, e.g., following [these guidelines](https://chris.beams.io/posts/git-commit/).
6+
7+
By submitting a pull request, you are licensing your code under the project [license](LICENSE) and affirming that you either own copyright (automatic for most individuals) or are authorized to distribute under the project license (e.g., in case your employer retains copyright on your work).

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2024, Kumar Anirudha
4+
Copyright (c) 2021-2022 Nico Schlömer
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<p align="center">
2+
<a href="https://github.com/anistark/sot"><img alt="tiptop" src="./images/sot.png" width="200px"/></a>
3+
<p align="center">Command-line system oberving tool.</p>
4+
</p>
5+
6+
`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.
7+
8+
Install and run with
9+
10+
<!--pytest-codeblocks: skip-->
11+
12+
```sh
13+
pip install sot
14+
sot
15+
```
16+
17+
For all options, see
18+
19+
<!--pytest-codeblocks:skipif(sys.version_info < (3, 10))-->
20+
21+
```sh
22+
sot -H
23+
```
24+
25+
<!--pytest-codeblocks: expected-output-->
26+
27+
```
28+
usage: sot [--help] [--version] [--log LOG] [--net NET]
29+
30+
Command-line System Obervation Tool ≈
31+
32+
options:
33+
--help, -H Show this help message and exit.
34+
--version, -V Display version information
35+
--log, -L LOG Debug log file
36+
--net, -N NET Network interface to display (default: auto)
37+
```
38+
39+
Main Theme:
40+
41+
| Color | Hex | RGB |
42+
| --- | --- | --- |
43+
| sky_blue3 | `#5fafd7` | `rgb(95,175,215)` |
44+
| aquamarine3 | `#5fd7af` | `rgb(95,215,175)` |
45+
| yellow | `#808000` | `rgb(128,128,0)` |
46+
| bright_black | `#808080` | `rgb(128,128,128)` |
47+
| slate_blue1 | `#875fff` | `rgb(135,95,255)` |
48+
| red3 | `#d70000` | `rgb(215,0,0)` |
49+
| dark_orange | `#d75f00` | `rgb(215,95,0)` |
50+
51+
All supported [colors](https://rich.readthedocs.io/en/latest/appendix/colors.html).
52+
53+
---
54+
55+
<p align="center">
56+
<p align="center">🏴 ≈ 🏴</p>
57+
</p>
58+
59+
---
60+
61+
`sot` uses [Textual](https://github.com/willmcgugan/textual/) for layouting, [rich](https://rich.readthedocs.io/en/latest/index.html) for rich text and [psutil](https://github.com/giampaolo/psutil) for fetching system data.
62+
63+
Other top alternatives in alphabetical order:
64+
65+
- [tiptop](https://github.com/nschloe/tiptop) ✨ This project was created on top of `tiptop`, when it became unmaintained.
66+
- [bashtop](https://github.com/aristocratos/bashtop), [bpytop](https://github.com/aristocratos/bpytop), [btop](https://github.com/aristocratos/btop)
67+
- [bottom](https://github.com/ClementTsang/bottom) (one of my fav)
68+
- [Glances](https://github.com/nicolargo/glances)
69+
- [gtop](https://github.com/aksakalli/gtop)
70+
- [htop](https://github.com/htop-dev/htop)

images/orb.png

192 KB
Loading

images/sot.png

8.1 KB
Loading

justfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version := `python3 -c "from src.sot.__about__ import __version__; print(__version__)"`
2+
3+
default:
4+
@echo "\"just publish\"?"
5+
6+
publish: clean
7+
@if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then exit 1; fi
8+
gh release create "v{{version}}"
9+
python3 -m build --sdist --wheel .
10+
twine upload dist/*
11+
12+
clean:
13+
@find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
14+
@rm -rf src/*.egg-info/ build/ dist/ .tox/
15+
16+
format:
17+
isort .
18+
black .
19+
blacken-docs README.md
20+
21+
lint:
22+
black --check .
23+
flake8 .

pyproject.toml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[build-system]
2+
requires = ["setuptools>=61"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.isort]
6+
profile = "black"
7+
8+
[project]
9+
name = "sot"
10+
authors = [{name = "Kumar Anirudha", email = "dev@anirudha.dev"}]
11+
description = "System Oberving Tool"
12+
readme = "README.md"
13+
license = {file = "LICENSE"}
14+
classifiers = [
15+
"Development Status :: 4 - Beta",
16+
"License :: OSI Approved :: MIT License",
17+
"Operating System :: POSIX :: Linux",
18+
"Operating System :: MacOS",
19+
"Programming Language :: Python",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.7",
22+
"Programming Language :: Python :: 3.8",
23+
"Programming Language :: Python :: 3.9",
24+
"Programming Language :: Python :: 3.10",
25+
"Topic :: Utilities",
26+
]
27+
dynamic = ["version"]
28+
requires-python = ">=3.7"
29+
dependencies = [
30+
"py-cpuinfo",
31+
"distro",
32+
"psutil",
33+
"rich >= 11.0.0",
34+
"textual >=0.1.15, <0.2",
35+
]
36+
37+
[tool.setuptools.dynamic]
38+
version = {attr = "sot.__about__.__version__"}
39+
40+
[project.urls]
41+
Code = "https://github.com/anistark/sot"
42+
Issues = "https://github.com/anistark/sot/issues"
43+
44+
[project.scripts]
45+
sot = "sot._app:run"

setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python
2+
3+
import setuptools
4+
5+
if __name__ == "__main__":
6+
setuptools.setup()

src/sot/__about__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from datetime import datetime
2+
3+
__version__ = "1.0.0"
4+
__current_year__ = datetime.now().year

src/sot/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from .__about__ import __version__, __current_year__
2+
from ._app import run
3+
from .blockchar_stream import BlockCharStream
4+
from .braille_stream import BrailleStream
5+
6+
__all__ = ["BrailleStream", "BlockCharStream", "run", "__version__", "__current_year__"]

src/sot/_app.py

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
from __future__ import annotations
2+
3+
import argparse
4+
from sys import version_info
5+
6+
from textual.app import App
7+
8+
from .__about__ import __version__, __current_year__
9+
from ._cpu import CPU
10+
from ._disk import Disk
11+
from ._info import InfoLine
12+
from ._mem import Mem
13+
from ._net import Net
14+
from ._procs_list import ProcsList
15+
# from ._sot import Sot
16+
17+
def run(argv=None):
18+
parser = argparse.ArgumentParser(
19+
description="Command-line System Obervation Tool ≈",
20+
formatter_class=argparse.RawTextHelpFormatter,
21+
add_help=False
22+
)
23+
24+
parser.add_argument(
25+
"--help",
26+
"-H",
27+
action="help",
28+
default=argparse.SUPPRESS,
29+
help="Show this help message and exit."
30+
)
31+
32+
parser.add_argument(
33+
"--version",
34+
"-V",
35+
action="version",
36+
version=_get_version_text(),
37+
help="Display version information",
38+
)
39+
40+
parser.add_argument(
41+
"--log",
42+
"-L",
43+
type=str,
44+
default=None,
45+
help="Debug log file",
46+
)
47+
48+
parser.add_argument(
49+
"--net",
50+
"-N",
51+
type=str,
52+
default=None,
53+
help="Network interface to display (default: auto)",
54+
)
55+
56+
args = parser.parse_args(argv)
57+
58+
# with a grid
59+
class sotApp(App):
60+
async def on_mount(self) -> None:
61+
grid = await self.view.dock_grid(edge="left")
62+
63+
grid.add_column(fraction=36, name="left")
64+
# grid.add_column(fraction=15, name="middle")
65+
# grid.add_column(fraction=36, name="right")
66+
grid.add_column(fraction=45, name="right")
67+
68+
grid.add_row(size=1, name="r0")
69+
grid.add_row(fraction=1, name="r1")
70+
grid.add_row(fraction=1, name="r2")
71+
grid.add_row(fraction=1, name="r3")
72+
grid.add_areas(
73+
area0="left-start|right-end,r0",
74+
area1="left,r1",
75+
# area2a="middle,r1-start|r1-end",
76+
# area2b="middle,r2-start|r2-end",
77+
# area2c="middle,r3-start|r3-end",
78+
area3a="right,r1",
79+
area3b="right,r2",
80+
area3c="right,r3",
81+
area4="left,r2-start|r3-end",
82+
)
83+
grid.place(
84+
area0=InfoLine(),
85+
area1=CPU(),
86+
# area2b=Sot(),
87+
area3a=Mem(),
88+
area3b=Disk(),
89+
area3c=Net(args.net),
90+
area4=ProcsList(),
91+
)
92+
93+
async def on_load(self, _):
94+
await self.bind("q", "quit", "quit")
95+
96+
sotApp.run(log=args.log)
97+
98+
99+
def _get_version_text():
100+
python_version = f"{version_info.major}.{version_info.minor}.{version_info.micro}"
101+
102+
return "\n".join(
103+
[
104+
f"sot {__version__} [Python {python_version}]",
105+
f"Copyright (c) 2024-{__current_year__} Kumar Anirudha",
106+
]
107+
)

0 commit comments

Comments
 (0)