From 3bd942d471a801b0f6f1ad84bf3e1ca948ac8ef0 Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Tue, 15 Nov 2022 09:29:32 +0100 Subject: [PATCH] Skip versions without server jar --- build.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index ef3cc1d..d324abb 100755 --- a/build.py +++ b/build.py @@ -39,10 +39,10 @@ class DownloadInfo(TypedDict): class VersionDownloads(TypedDict): - client: DownloadInfo - client_mappings: DownloadInfo - server: DownloadInfo - server_mappings: DownloadInfo + client: NotRequired[DownloadInfo] + client_mappings: NotRequired[DownloadInfo] + server: NotRequired[DownloadInfo] + server_mappings: NotRequired[DownloadInfo] class VersionManifestFull(TypedDict): @@ -152,6 +152,9 @@ default_java_version: JavaVersion = { "majorVersion": 8 } +class NoServerException(Exception): + pass + def build_version(manifest: VersionManifest, version_id: str, repository: str = "hub.cnml.de/minecraft"): matching_version = list( filter(lambda v: v["id"] == version_id, manifest["versions"])) @@ -162,7 +165,10 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str = print( f"Version [{version['type']}] {version['id']} requires java version {java_version['majorVersion']} ({java_version['component']})") server_jar_file = Path("versions") / version['id'] / "server.jar" - server_jar = version["downloads"]["server"] + server_jar = version["downloads"].get("server") + if server_jar is None: + raise NoServerException(f"No server build exists for {version['id']} (Java {java_version['majorVersion']})") + download_file(server_jar, server_jar_file) build_args: DockerfileBuildArgs = { @@ -204,8 +210,11 @@ if __name__ == "__main__": versions: list[str] = list(version["id"] for version in manifest["versions"] if version["type"] == "release") if args.all else args.versions for version_id in versions: + print() try: build_version(manifest, version_id) + except NoServerException as e: + print(e) except Exception as e: print(f"Failed building images for version {version_id}") if args.force: