Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .circleci/config.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches: ["main", "master"]
pull_request:
branches: ["main", "master"]

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: poetry install --with dev

- name: Lint with ruff
run: poetry run ruff check .

- name: Type check with mypy
run: poetry run mypy

- name: Run tests
run: poetry run pytest --cov=pingtop --cov-report=term-missing
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
pingtop
=======

.. image:: https://github.com/laixintao/pingtop/actions/workflows/ci.yml/badge.svg
:target: https://github.com/laixintao/pingtop/actions/workflows/ci.yml
:alt: CI

``pingtop`` is a fast, keyboard-first multi-host ping monitor for people who live in the terminal.
Point it at a few hosts, a whole subnet, or a host list, and get a live Textual dashboard with RTT trends, loss stats, sortable columns, and per-host drill-down details.

Expand Down
5 changes: 4 additions & 1 deletion src/pingtop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,10 @@ def _log_fd_usage(self, now: float) -> None:
if fd_count is None:
logger.debug("fd_count unavailable")
return
logger.debug("fd_count=%s hosts=%s pending_updates=%s", fd_count, len(self.session.hosts), len(self._pending_updates))
logger.debug(
"fd_count=%s hosts=%s pending_updates=%s",
fd_count, len(self.session.hosts), len(self._pending_updates),
)

@staticmethod
def _open_fd_count() -> int | None:
Expand Down
Empty file added src/pingtop/py.typed
Empty file.
9 changes: 6 additions & 3 deletions src/pingtop/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ def render_summary(
)

status_text, status_color = _status(snapshot)
loss_pct = f"{_loss_percent(total_lost, total_sent):.1f}%"
loss_styled = style(loss_pct, fg=_loss_color(total_lost, total_sent), bold=True)
parts = [
style(status_text, fg=status_color, bold=True),
f"{total_hosts} hosts",
f"tx {total_sent}",
f"rx {total_received}",
f"loss {style(f'{_loss_percent(total_lost, total_sent):.1f}%', fg=_loss_color(total_lost, total_sent), bold=True)}",
f"loss {loss_styled}",
]
if error_hosts:
parts.append(f"err {style(str(error_hosts), fg='red', bold=True)}")
Expand Down Expand Up @@ -107,7 +109,8 @@ def _status(snapshot: SessionSnapshot) -> tuple[str, str]:
for host in snapshot.hosts
)
has_down = any(
int(cast(int, host["seq"])) > 0 and int(cast(int, host["lost"])) == int(cast(int, host["seq"]))
int(cast(int, host["seq"])) > 0
and int(cast(int, host["lost"])) == int(cast(int, host["seq"]))
for host in snapshot.hosts
)
has_loss = int(cast(int, snapshot.aggregates["total_lost"])) > 0
Expand Down Expand Up @@ -135,6 +138,6 @@ def _styler(color: bool):
def apply(text: str, **styles: object) -> str:
if not color:
return text
return click.style(text, **styles)
return click.style(text, **styles) # type: ignore[arg-type] # kwargs match click.style

return apply
Loading