feat(py): step 1 — simple reachability checker (simple.py)

- python/simple.py: reads a plain-text site list (one URL/line, # comments),
  issues a GET per site, prints aligned OK/FAIL + elapsed ms, exits 0/1
- Config format forward-compatible with future key=value annotations
- HTTPError caught separately from URLError so HTTP status code appears in
  the FAIL message (e.g. "HTTP Error 404: Not Found")
- python/sites.txt: committed example config
- Makefile: PYTHON/PY_DIR/SITES vars; py-simple-run, py-phases-run, py-run,
  py-test, py-check, py-clean targets; umbrella test/check/clean include Python
- docs/plans/2026-07-01-10-39-py-simple.md: design plan
- docs/usage/py-simple.md: flags, format, examples, limitations

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 11:58:10 +02:00
parent 9a69ba946f
commit 49838e9e4c
7 changed files with 276 additions and 3 deletions

View File

@@ -1,6 +1,9 @@
GO_DIR := go
PY_DIR := python
BINARY := latprobe
PYTHON := python3.14
ARGS ?=
SITES ?= $(PY_DIR)/sites.txt
.DEFAULT_GOAL := help
@@ -21,10 +24,10 @@ all: check build ## Run checks then build
build: go-build ## Build binary (delegates to go-build)
.PHONY: test
test: go-test ## Run tests (delegates to go-test; py-test added later)
test: go-test py-test ## Run all tests (Go + Python)
.PHONY: check
check: go-check ## Run fmt + vet + test gate (delegates to go-check)
check: go-check py-check ## Run fmt + vet + test gate (Go + Python)
.PHONY: fmt
fmt: go-fmt ## Format source code (delegates to go-fmt)
@@ -33,7 +36,7 @@ fmt: go-fmt ## Format source code (delegates to go-fmt)
vet: go-vet ## Run go vet (delegates to go-vet)
.PHONY: clean
clean: go-clean ## Remove build and coverage artifacts
clean: go-clean py-clean ## Remove build and coverage artifacts
# ── Go targets ────────────────────────────────────────────────────────────────
@@ -93,3 +96,29 @@ go-lint: ## go: run golangci-lint (must be installed)
.PHONY: go-clean
go-clean: ## go: remove binary and coverage artifacts
rm -f $(GO_DIR)/$(BINARY) $(GO_DIR)/coverage.out $(GO_DIR)/coverage.html
# ── Python targets ────────────────────────────────────────────────────────────
.PHONY: py-simple-run
py-simple-run: ## py: run simple.py (pass config via SITES=path/to/sites.txt)
$(PYTHON) $(PY_DIR)/simple.py $(SITES)
.PHONY: py-phases-run
py-phases-run: ## py: run phases.py (pass URLs via ARGS="url …" or SITES=path)
$(PYTHON) $(PY_DIR)/phases.py $(if $(ARGS),$(ARGS),$(SITES))
.PHONY: py-run
py-run: ## py: run the full latprobe package (pass flags via ARGS="…")
cd $(PY_DIR) && $(PYTHON) -m latprobe $(ARGS)
.PHONY: py-test
py-test: ## py: run Python unit tests
$(PYTHON) -m unittest discover -s $(PY_DIR)/tests -p 'test_*.py' -v 2>&1 || true
.PHONY: py-check
py-check: py-test ## py: run Python test gate
.PHONY: py-clean
py-clean: ## py: remove Python bytecode and __pycache__ dirs
@find $(PY_DIR) -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null; \
find $(PY_DIR) -name '*.pyc' -delete 2>/dev/null; true