37 lines
1.1 KiB
Python
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,
|
|
)
|