mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-10-04 20:46:43 +00:00
Adds the OCI manager: an engine that turns a Docker Compose file into an LXC definition, a catalog of 365 applications drawn from LinuxServer.io and other container image sources, and a per-instance registry recording what each container was built from. Reachable from the main menu. Catalog text is translated like every other string in the project: the taglines go through translate() and land in lang/*.json, so the entries read in all eight languages instead of only English. Translation cache builder: - a failed translation leaves the key absent rather than writing English, which previously made the string count as translated forever - a result identical to a 3+ word source is rejected, catching a provider that silently returns the text it was given - strings that are nothing but glossary terms keep their source spelling instead of being discarded as failures - no backoff between attempts when the provider is deterministic - application names are protected so "HAOS One" survives translation - argos joins the provider list, and the workflow reads the OCI sources Audit & Report: - findings that moved in the wrong direction between runs are reported alongside the ones that improved - an accepted risk can carry a review date and is flagged when it falls due - backup checks explain in plain language what they looked at and what to do next Monitor: - disks can be excluded from periodic reads, and an idle disk says so instead of showing a stale temperature - per-disk identity survives a controller or enclosure change - scheduled Borg backups resolve their SSH key from the repository entry - PVE upgrades log the package list and the resulting dpkg changes The web build no longer copies scripts/ into public/: the documentation links to GitHub, so nothing read that folder. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
135 lines
3.7 KiB
Python
135 lines
3.7 KiB
Python
"""Terminal output in the ProxMenux style of utils.sh (msg_info, msg_ok, ...)."""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import textwrap
|
|
import threading
|
|
|
|
from .i18n import BASE_DIR
|
|
|
|
MG = "\033[1;35m"
|
|
GN = "\033[1;92m"
|
|
RD = "\033[01;31m"
|
|
YW = "\033[33m"
|
|
YWB = "\033[1;33m"
|
|
BL = "\033[36m"
|
|
BOLD = "\033[1m"
|
|
CL = "\033[m"
|
|
BFR = "\r\033[K"
|
|
TAB = " "
|
|
HOLD = "-"
|
|
CM = f"{GN}✓ {CL}"
|
|
FRAMES = ("⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏")
|
|
|
|
_spinner: tuple[threading.Thread, threading.Event] | None = None
|
|
|
|
|
|
def _write(text: str) -> None:
|
|
sys.stdout.write(text)
|
|
sys.stdout.flush()
|
|
|
|
|
|
def _spin(stop: threading.Event) -> None:
|
|
index = 0
|
|
_write("\033[?25l")
|
|
while not stop.wait(0.1):
|
|
_write(f"\r {MG}{FRAMES[index]}{CL}")
|
|
index = (index + 1) % len(FRAMES)
|
|
|
|
|
|
def stop_spinner(clear_line: bool = True) -> None:
|
|
global _spinner
|
|
if _spinner is not None:
|
|
thread, stop = _spinner
|
|
stop.set()
|
|
thread.join()
|
|
_spinner = None
|
|
if clear_line:
|
|
_write("\r\033[K")
|
|
_write("\033[?25h")
|
|
|
|
|
|
def msg_info(text: str) -> None:
|
|
global _spinner
|
|
stop_spinner()
|
|
_write(f"{TAB}{MG}{HOLD}{text}")
|
|
if sys.stdout.isatty():
|
|
stop = threading.Event()
|
|
thread = threading.Thread(target=_spin, args=(stop,), daemon=True)
|
|
_spinner = (thread, stop)
|
|
thread.start()
|
|
else:
|
|
_write("\n")
|
|
|
|
|
|
def msg_ok(text: str) -> None:
|
|
stop_spinner(clear_line=False)
|
|
_write(f"{BFR}{TAB}{CM}{GN}{text}{CL}\n")
|
|
|
|
|
|
def msg_warn(text: str) -> None:
|
|
stop_spinner(clear_line=False)
|
|
_write(f"{BFR}{TAB}{CL} {YWB}{text}{CL}\n")
|
|
|
|
|
|
def msg_error(text: str) -> None:
|
|
stop_spinner(clear_line=False)
|
|
_write(f"{BFR}{TAB}{RD}[ERROR] {text}{CL}\n")
|
|
|
|
|
|
def msg_info2(text: str) -> None:
|
|
_write(f"{TAB}{BOLD}{YW}{HOLD} {text}{CL}\n")
|
|
|
|
|
|
def msg_note(text: str) -> None:
|
|
"""Closing information, in the colour ProxMenux uses for paths and values."""
|
|
stop_spinner(clear_line=False)
|
|
_write(f"{TAB}{BL}{text}{CL}\n")
|
|
|
|
|
|
def msg_success(text: str) -> None:
|
|
stop_spinner(clear_line=False)
|
|
_write(f"{TAB}{BOLD}{BL}{HOLD}{text}{CL}\n\n")
|
|
|
|
|
|
def ask_yes_no(text: str, default_yes: bool = True) -> bool:
|
|
"""A question asked in the middle of the output: whiptail draws over the
|
|
terminal and restores it, so what was printed stays on screen."""
|
|
width = 74
|
|
lines = sum(max(1, len(textwrap.wrap(line, width - 6) or [''])) for line in text.splitlines() or [''])
|
|
widget = ['whiptail', '--backtitle', 'ProxMenux', '--title', 'ProxMenux',
|
|
'--yesno', text, str(min(lines + 8, 20)), str(width)]
|
|
if not default_yes:
|
|
widget.insert(1, '--defaultno')
|
|
if shutil.which('whiptail'):
|
|
environment = dict(os.environ, NEWT_COLORS_FILE='/dev/null')
|
|
return subprocess.run(widget, env=environment, check=False).returncode == 0
|
|
answer = input(f"{text} [{'Y/n' if default_yes else 'y/N'}]: ").strip().casefold()
|
|
return default_yes if not answer else answer in {'y', 'yes', 's', 'si'}
|
|
|
|
|
|
def msg_title(text: str) -> None:
|
|
_write(f"\n\n{TAB}{BOLD}{HOLD} | {text} | {HOLD}{CL}\n\n\n")
|
|
|
|
|
|
def show_logo() -> None:
|
|
"""The ProxMenux banner; like show_proxmenux_logo it clears the screen."""
|
|
stop_spinner()
|
|
utils = BASE_DIR / "utils.sh"
|
|
if utils.is_file() and sys.stdout.isatty():
|
|
subprocess.run(["bash", "-c", 'source "$1" >/dev/null 2>&1; show_proxmenux_logo', "_", str(utils)],
|
|
check=False)
|
|
elif sys.stdout.isatty():
|
|
_write("\033[H\033[2J")
|
|
|
|
|
|
def wait_for_enter(text: str) -> None:
|
|
msg_success(text)
|
|
try:
|
|
input()
|
|
except EOFError:
|
|
pass
|