Python Rewrite #2

Merged
msrogers2015 merged 18 commits from feat/python-rewrite into main 2026-06-17 03:01:51 +00:00
Owner

Converted the project from fully bash to mostly python. The initial attempt over complicated the project for no reason when python is my main language and should've been the selected language from the start. The core checks are fully functional on the three main package managers: apt, dnf, and pacman. Functions completed in this merge includes:

  • Checking and installing python if required using bash
  • Checking and installing venv for python if required using python
  • Checking and installing docker if required.
  • Checking docker is running
  • Checking and installing docker compose if required.

The setup (init) function is configured in a manner that can be reran to install any potential new packages added to requirements.txt

Converted the project from fully bash to mostly python. The initial attempt over complicated the project for no reason when python is my main language and should've been the selected language from the start. The core checks are fully functional on the three main package managers: apt, dnf, and pacman. Functions completed in this merge includes: - Checking and installing python if required using bash - Checking and installing venv for python if required using python - Checking and installing docker if required. - Checking docker is running - Checking and installing docker compose if required. The setup (init) function is configured in a manner that can be reran to install any potential new packages added to requirements.txt
Step 2 UI half. Replaces the bash equivalents from refact/restructure
with Python using rich and questionary.

- diycloud/ui/output.py: status helpers (info/success/warn/error/step),
  block helpers (heading/rule/banner), inline helpers (bold/dim).
  Stdout vs stderr routing matches the bash version. Color/TTY
  detection handled by rich.

- diycloud/ui/validate.py: pure validators (domain, email, subdomain,
  port, timezone, service_name) returning None for valid or an error
  string. Composable; usable from both prompts and config validation.

- diycloud/ui/prompt.py: questionary wrappers (text, password, yes_no,
  choice) with diycloud conventions. Internal _adapt() bridges the
  None|str validator convention to questionary's True|str convention.
  Ctrl-C raises KeyboardInterrupt instead of returning None.
- tests/ui/test_validate.py: parametrized tests for each validator,
  weighted toward invalid-input edge cases (URL-as-domain, missing
  TLD, reserved service names, etc.) over redundant valid cases.

- tests/ui/test_prompt.py: mocks questionary to verify wrapper logic
  without TTY input. Focuses on Ctrl-C handling and the _adapt() layer
  that translates between diycloud's None|str validator convention
  and questionary's True|str convention.

- tests/core/test_manifest.py: smoke tests for each Pydantic model
  plus explicit cross-field check coverage on RegisteredService.

Test infrastructure:

- requirements-dev.txt with pytest as a dev-only dependency
- tests/ at repo root, mirroring package structure
- Run with: PYTHONPATH=. .venv/bin/pytest

Also fixes RegisteredService cross-field validation in
diycloud/core/manifest.py: moved from a custom __init__ to a
model_validator(mode="after") so Pydantic's field validation
doesn't preempt our TypeError when config_class doesn't inherit
from ServiceConfigBase.
Updating with a new method that should be more managable as well as easier to use and read. This also fully covers ensuring all requirements are present.
msrogers2015 changed title from WIP: Python Rewrite to Python Rewrite 2026-06-17 03:00:22 +00:00
msrogers2015 deleted branch feat/python-rewrite 2026-06-17 03:01:53 +00:00
msrogers2015 referenced this pull request from a commit 2026-06-17 03:01:53 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
msrogers2015/diy-cloud!2
No description provided.