2026-04-13 19:44:29 +02:00
|
|
|
from drives import list_scored_devices
|
ci: add Forgejo Actions workflow with ruff, pytest, JSON + link checks
- .forgejo/workflows/ci.yml: four jobs (lint, test, validate-json,
markdown-links) running on push to main and on pull requests
- pyproject.toml: project metadata, flask dep, dev extras (ruff, pytest),
ruff config (E/F/I/W/B/UP rulesets, 100-char lines, py311 target),
pytest config (pythonpath=webinstaller so tests can import drives)
- tests/test_drives.py: 11 unit tests covering parse_size_gb (TB/GB/MB,
European comma decimal, empty input, unknown units), drive type
scoring (nvme/ssd/hdd), size scoring bands, and score_device summing
- .gitignore: ignore .pytest_cache, *.egg-info, .ruff_cache
- webinstaller/drives.py: refactor subprocess.run to capture_output
kwarg (ruff UP022) — drops four lines, same behavior
- webinstaller/app.py: ruff-sorted imports (isort)
All checks pass locally: ruff check + format, pytest 11/11, JSON valid.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 20:24:05 +02:00
|
|
|
from flask import Flask, redirect, render_template, request, url_for
|
2026-04-13 19:38:34 +02:00
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
|
# Step 1
|
|
|
|
|
"hostname": "furtka",
|
|
|
|
|
"username": "",
|
|
|
|
|
"password": "",
|
|
|
|
|
"password2": "",
|
|
|
|
|
"backend": False,
|
|
|
|
|
"backend_adress": "127.0.0.1",
|
2026-04-13 19:44:29 +02:00
|
|
|
"language": "en",
|
2026-04-13 19:38:34 +02:00
|
|
|
# devices
|
2026-04-13 19:44:29 +02:00
|
|
|
"boot_drive_uuid": "",
|
2026-04-13 19:38:34 +02:00
|
|
|
}
|
|
|
|
|
|
2026-04-13 19:44:29 +02:00
|
|
|
|
2026-04-13 19:38:34 +02:00
|
|
|
@app.route("/")
|
|
|
|
|
def home():
|
|
|
|
|
return "Hello World"
|
|
|
|
|
|
2026-04-13 19:44:29 +02:00
|
|
|
|
2026-04-13 19:38:34 +02:00
|
|
|
@app.route("/install/step1", methods=["GET", "POST"])
|
|
|
|
|
def install_step_1():
|
|
|
|
|
if request.method == "POST":
|
|
|
|
|
settings["hostname"] = request.form["hostname"]
|
|
|
|
|
return redirect(url_for("install_step_2"))
|
|
|
|
|
return render_template("install/step1.html")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/install/step2", methods=["GET", "POST"])
|
|
|
|
|
def install_step_2():
|
|
|
|
|
if request.method == "POST":
|
|
|
|
|
settings["boot_drive_uuid"] = request.form["boot_drive_uuid"]
|
|
|
|
|
return redirect(url_for("install_overview"))
|
2026-04-13 19:44:29 +02:00
|
|
|
return render_template("install/step2.html", drives=list_scored_devices())
|
2026-04-13 19:38:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/install/overview")
|
|
|
|
|
def install_overview():
|
|
|
|
|
return render_template("install/overview.html", settings=settings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
app.run(debug=True, port=5000)
|