feat(extension): add Spoolman Docker installer (#669)

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2025-03-30 17:57:46 +02:00
committed by GitHub
parent 1a6f06eaf2
commit c91816d13f
11 changed files with 626 additions and 13 deletions

View File

@@ -52,16 +52,16 @@ def get_confirm(question: str, default_choice=True, allow_go_back=False) -> bool
def get_number_input(
question: str,
min_count: int,
max_count: int | None = None,
min_value: int,
max_value: int | None = None,
default: int | None = None,
allow_go_back: bool = False,
) -> int | None:
"""
Helper method to get a number input from the user
:param question: The question to display
:param min_count: The lowest allowed value
:param max_count: The highest allowed value (or None)
:param min_value: The lowest allowed value
:param max_value: The highest allowed value (or None)
:param default: Optional default value
:param allow_go_back: Navigate back to a previous dialog
:return: Either the validated number input, or None on go_back
@@ -77,7 +77,7 @@ def get_number_input(
return default
try:
return validate_number_input(_input, min_count, max_count)
return validate_number_input(_input, min_value, max_value)
except ValueError:
Logger.print_error(INVALID_CHOICE)

View File

@@ -359,11 +359,12 @@ def get_ipv4_addr() -> str:
try:
# doesn't even have to be reachable
s.connect(("192.255.255.255", 1))
return str(s.getsockname()[0])
except Exception:
return "127.0.0.1"
finally:
ipv4: str = str(s.getsockname()[0])
s.close()
return ipv4
except Exception:
s.close()
return "127.0.0.1"
def download_file(url: str, target: Path, show_progress=True) -> None:
@@ -600,3 +601,33 @@ def get_distro_info() -> Tuple[str, str]:
raise ValueError("Error reading distro version!")
return distro_id.lower(), distro_version
def get_system_timezone() -> str:
timezone = "UTC"
try:
with open("/etc/timezone", "r") as f:
timezone = f.read().strip()
except FileNotFoundError:
# fallback to reading timezone from timedatectl
try:
result = run(
["timedatectl", "show", "--property=Timezone"],
capture_output=True,
text=True,
check=True,
)
timezone = result.stdout.strip().split("=")[1]
except CalledProcessError:
# fallback if timedatectl fails, try reading from readlink
try:
result = run(
["readlink", "-f", "/etc/localtime"],
capture_output=True,
text=True,
check=True,
)
timezone = result.stdout.strip().split("zoneinfo/")[1]
except (CalledProcessError, IndexError):
Logger.print_warn("Could not determine system timezone, using UTC")
return timezone