left4me/l4d2host/steam_install.py
2026-05-05 23:47:06 +02:00

37 lines
1.1 KiB
Python

from pathlib import Path
from typing import Callable
from l4d2host.process import run_command
class SteamInstaller:
def __init__(self, install_dir: Path = Path("/opt/l4d2/installation"), steamcmd: str = "steamcmd"):
self.install_dir = install_dir
self.steamcmd = steamcmd
def install_or_update(
self,
*,
on_stdout: Callable[[str], None] | None = None,
on_stderr: Callable[[str], None] | None = None,
passthrough: bool = False,
) -> None:
for platform in ("windows", "linux"):
run_command(
[
self.steamcmd,
"+force_install_dir",
str(self.install_dir),
"+login",
"anonymous",
"+@sSteamCmdForcePlatformType",
platform,
"+app_update",
"222860",
"validate",
"+quit",
],
on_stdout=on_stdout,
on_stderr=on_stderr,
passthrough=passthrough,
)