From ac28d632d90994b04d9dd21f17f32881d77fe823 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 25 Apr 2024 22:27:10 -0700 Subject: [PATCH] server config is now toml format instead of yaml --- .efrocachemap | 50 +++---- CHANGELOG.md | 5 + .../.idea/dictionaries/ericf.xml | 3 +- config/projectconfig.json | 4 +- config/requirements.txt | 3 +- config/spinoffconfig.py | 2 +- config/toolconfigsrc/pyrightconfig.toml | 2 +- src/assets/.asset_manifest_private.json | 36 ----- src/assets/Makefile | 36 ----- src/assets/server_package/README.txt | 4 +- .../server_package/ballisticakit_server.py | 24 ++-- ...fig_template.yaml => config_template.toml} | 4 +- tools/batools/build.py | 127 +++++++++--------- tools/batools/staging.py | 8 +- tools/efrotools/toolconfig.py | 2 +- 15 files changed, 105 insertions(+), 205 deletions(-) rename src/assets/server_package/{config_template.yaml => config_template.toml} (55%) diff --git a/.efrocachemap b/.efrocachemap index 5e29f6a9..4b4d16f6 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -945,29 +945,11 @@ "build/assets/ba_data/meshes/zoeTorso.bob": "26a1007e98902178d8c62fd7069d5da5", "build/assets/ba_data/meshes/zoeUpperArm.bob": "a8a881010ac1ee9ec5ca872d5c5e853a", "build/assets/ba_data/meshes/zoeUpperLeg.bob": "95b2502f74c70f934927f67cd505c3ad", - "build/assets/ba_data/python-site-packages/_yaml/__init__.py": "b09d1968d73a04d6cf20e4e79657a6e7", "build/assets/ba_data/python-site-packages/certifi/__init__.py": "98360d9e66de68a618eed6098a65405b", "build/assets/ba_data/python-site-packages/certifi/__main__.py": "ef02e73f8581609df189a9f61aca365b", "build/assets/ba_data/python-site-packages/certifi/cacert.pem": "4e587dca9ab75057ffef6658ed385ff2", "build/assets/ba_data/python-site-packages/certifi/core.py": "c1b8c102093ea26587619677c7ec6016", "build/assets/ba_data/python-site-packages/typing_extensions.py": "f1af94a03caf6fc79be0aedc8ab03090", - "build/assets/ba_data/python-site-packages/yaml/__init__.py": "2b747e5772c203377222afc888ac6b71", - "build/assets/ba_data/python-site-packages/yaml/composer.py": "cef871e1f5f99ba2a7c44941b70afb06", - "build/assets/ba_data/python-site-packages/yaml/constructor.py": "8a15e361e34b79491c81553bb3534062", - "build/assets/ba_data/python-site-packages/yaml/cyaml.py": "9b11cba12e6f1cf2efe1725a20d7e1e5", - "build/assets/ba_data/python-site-packages/yaml/dumper.py": "b2cb6b4883f3504bb0255bfce6c3b09f", - "build/assets/ba_data/python-site-packages/yaml/emitter.py": "4c9bec47c3d0398c452f43a4344b2e71", - "build/assets/ba_data/python-site-packages/yaml/error.py": "e419d0e3ccb94a42881b565d285b6c9a", - "build/assets/ba_data/python-site-packages/yaml/events.py": "3e36b40c15962a78747acde2d434518d", - "build/assets/ba_data/python-site-packages/yaml/loader.py": "46f0fc4e2aef0b002bf56c87340a2650", - "build/assets/ba_data/python-site-packages/yaml/nodes.py": "43e867bb7f3cd06e0108837d9fd2a892", - "build/assets/ba_data/python-site-packages/yaml/parser.py": "d5225a0995e6802f440f7bc0bce34905", - "build/assets/ba_data/python-site-packages/yaml/reader.py": "a73be6f8420c9d02c8fe88c06c4b4dab", - "build/assets/ba_data/python-site-packages/yaml/representer.py": "8af292de41185af996c8f35ca1a96663", - "build/assets/ba_data/python-site-packages/yaml/resolver.py": "79802aa2c45560625a19e0eab318e45e", - "build/assets/ba_data/python-site-packages/yaml/scanner.py": "09239836ea50e81db330635e71460baa", - "build/assets/ba_data/python-site-packages/yaml/serializer.py": "baf67e938b13a5a3625d50d8b56180d7", - "build/assets/ba_data/python-site-packages/yaml/tokens.py": "9530e25e7cc2dfa36cff6fddc1578d9a", "build/assets/ba_data/textures/achievementBoxer.dds": "5b5c461e67f3a92105b56fe264a7dd28", "build/assets/ba_data/textures/achievementBoxer.ktx": "1055e009423ea1d0bc3b172f9d7328bb", "build/assets/ba_data/textures/achievementBoxer.pvr": "48f212189a6d83d29be410613b4f0005", @@ -4064,18 +4046,18 @@ "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "5fe54ba7d7250a4e88203ddc7d122d72", "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "d36e3dfb83b4d4a4eeb3c5221a230d31", "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "676a86a2235dc5feeb5b2ac50faef8c3", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "c3f9e038e33af20df864ac218a0a4f29", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "b094a46a8d4376f0de49e51b979b8833", "build/prefab/full/mac_arm64_gui/release/ballisticakit": "a54c48845d6a222083e27a8eeacfcf4f", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "e8b988d8474bab7152239dd7cca2125b", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "fbe8abc5d637fd945a0c9cee358e32ae", "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "e85ad52a005548cdffec2d3f68c76c6c", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "c68c792ef7b89d961a0fc2f2c7a2a53d", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "31d588a5bde8b2028129001b5b3be192", "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "a9df28724e77a4f241561a8da401c6a4", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "6009222450e3d51276f31299364accd3", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "0d56f8b4c531f6e7f2d33bc0a5fd4ef2", "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "931e8d780ca39a9b4f6878c15cf34283", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "0f1ce2a8347fec692c121d3d980ed9dd", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "ac1775db2ccec6be00c59b915098d71a", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "097bce1746a439817e153b01067150b5", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "2ddec85274dfa4c41edf2e175e31071d", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "120259c59b3584db3b6e16711cc01c10", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "e6e8c688fd2540ba3f0402236d91fa2d", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "47eaa7e4c28292f47ab50aa90120325a", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "2858480f76f850ace31a37bc7ff5aeab", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "e40234644df79316d71808a731ba14f0", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "8563857336ffcf40abfeac81fc3955eb", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "e40234644df79316d71808a731ba14f0", @@ -4092,14 +4074,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "9768548c6dfdff65fb25661540025ffe", "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "1a0cc7e78dc66dec6ee85a8a0d68aefd", "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "9768548c6dfdff65fb25661540025ffe", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "4baede5ec7e5689ef398a07b2cd4d8b0", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "96f9084001fb46ae7f6b5c369dd54597", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "069e9d0c5dc09e93826a85f4888f13e0", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "4e1356a6e4d253df2768fd1619d981a6", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "d81cc208e26a6cfa37b8fa156a2bffba", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "a87689ec2c168833bb5e1753d0b360a6", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "f15c686d83350f1e6fcbc04bd7619775", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "4c32efd6dced334def9d466cb3df3d7f", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "d0ebeba4c65ae9d39e831e30ee526022", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "85d436353222ca21a15d71602753a5e6", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "73d6b99a4e8ada86a0328e62d33b3683", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "f6203b004d00432c08c2f47f170111b8", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "f1f41e53e35805a071f86c252adcb517", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "4addbf2b7b2bc99e13d91f5b14660239", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "585587b1488674c182f67b77fe7bcf4e", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "a8a272cd5146456f654d7b154e512404", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "b611c090513a21e2fe90e56582724e9d", "src/ballistica/base/mgen/pyembed/binding_base.inc": "72bfed2cce8ff19741989dec28302f3f", diff --git a/CHANGELOG.md b/CHANGELOG.md index 4abeb8aa..4d5531ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -601,6 +601,11 @@ can be useful for core engine code to directly and clearly point out problems that cannot be recovered from (Exceptions in such cases can tend to be 'handled' which leads to a broken or crashing app). +- The server config file is now in `toml` format instead of `yaml`. Python has + built in support for reading `toml` as of 3.11 which means we don't have to + bundle extra packages, and `toml` has more of a clean minimal design that + works well for config files. Also I plan to use it for AssetPackage + configuration stuff so this keeps things consistent. ### 1.7.23 (build 21178, api 8, 2023-07-19) diff --git a/ballisticakit-cmake/.idea/dictionaries/ericf.xml b/ballisticakit-cmake/.idea/dictionaries/ericf.xml index 424a4df3..9d52b536 100644 --- a/ballisticakit-cmake/.idea/dictionaries/ericf.xml +++ b/ballisticakit-cmake/.idea/dictionaries/ericf.xml @@ -1205,7 +1205,6 @@ objpath objset objsizes - objtoyaml objtypes obstack obvs @@ -2013,4 +2012,4 @@ zrot - \ No newline at end of file + diff --git a/config/projectconfig.json b/config/projectconfig.json index 1e16e3c3..a9d0a1ee 100644 --- a/config/projectconfig.json +++ b/config/projectconfig.json @@ -31,7 +31,6 @@ "astroid", "pylint.lint", "pytest", - "yaml", "requests", "typing_extensions", "cpplint", @@ -46,7 +45,8 @@ "openstep_parser", "daemon", "jinja2", - "jinja2.Environment" + "jinja2.Environment", + "tomlkit" ], "python_paths": [ "src/assets/ba_data/python", diff --git a/config/requirements.txt b/config/requirements.txt index fc66adb0..6f8b5a7a 100644 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -12,11 +12,10 @@ pytest==8.1.1 python-daemon==3.0.1 python-lsp-black==2.0.0 python-lsp-server==1.11.0 -PyYAML==6.0.1 requests==2.31.0 Sphinx==7.3.7 +tomlkit==0.12.4 types-certifi==2021.10.8.3 types-filelock==3.2.7 -types-PyYAML==6.0.12.20240311 types-requests==2.31.0.20240406 typing_extensions==4.11.0 diff --git a/config/spinoffconfig.py b/config/spinoffconfig.py index 87d57444..47d390eb 100644 --- a/config/spinoffconfig.py +++ b/config/spinoffconfig.py @@ -198,7 +198,7 @@ ctx.filter_file_names = { 'LICENSE', 'cloudtool', 'bacloud', - 'config_template.yaml', + 'config_template.toml', '.efrocachemap', } diff --git a/config/toolconfigsrc/pyrightconfig.toml b/config/toolconfigsrc/pyrightconfig.toml index b63cb49b..0534d739 100644 --- a/config/toolconfigsrc/pyrightconfig.toml +++ b/config/toolconfigsrc/pyrightconfig.toml @@ -1,4 +1,4 @@ -# Pyright's actual config is a json file but we're using yaml here so we +# Pyright's actual config is a json file but we're using toml here so we # can include lovely comments (yaml is a superset of json) and then we # bake it down into a json file. diff --git a/src/assets/.asset_manifest_private.json b/src/assets/.asset_manifest_private.json index db37a0e3..2b777d83 100644 --- a/src/assets/.asset_manifest_private.json +++ b/src/assets/.asset_manifest_private.json @@ -945,8 +945,6 @@ "ba_data/meshes/zoeUpperArm.bob", "ba_data/meshes/zoeUpperLeg.bob", "ba_data/python-site-packages/__pycache__/typing_extensions.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/_yaml/__init__.py", - "ba_data/python-site-packages/_yaml/__pycache__/__init__.cpython-312.opt-1.pyc", "ba_data/python-site-packages/certifi/__init__.py", "ba_data/python-site-packages/certifi/__main__.py", "ba_data/python-site-packages/certifi/__pycache__/__init__.cpython-312.opt-1.pyc", @@ -955,40 +953,6 @@ "ba_data/python-site-packages/certifi/cacert.pem", "ba_data/python-site-packages/certifi/core.py", "ba_data/python-site-packages/typing_extensions.py", - "ba_data/python-site-packages/yaml/__init__.py", - "ba_data/python-site-packages/yaml/__pycache__/__init__.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/composer.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/constructor.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/cyaml.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/dumper.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/emitter.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/error.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/events.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/loader.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/nodes.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/parser.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/reader.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/representer.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/resolver.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/scanner.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/serializer.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/__pycache__/tokens.cpython-312.opt-1.pyc", - "ba_data/python-site-packages/yaml/composer.py", - "ba_data/python-site-packages/yaml/constructor.py", - "ba_data/python-site-packages/yaml/cyaml.py", - "ba_data/python-site-packages/yaml/dumper.py", - "ba_data/python-site-packages/yaml/emitter.py", - "ba_data/python-site-packages/yaml/error.py", - "ba_data/python-site-packages/yaml/events.py", - "ba_data/python-site-packages/yaml/loader.py", - "ba_data/python-site-packages/yaml/nodes.py", - "ba_data/python-site-packages/yaml/parser.py", - "ba_data/python-site-packages/yaml/reader.py", - "ba_data/python-site-packages/yaml/representer.py", - "ba_data/python-site-packages/yaml/resolver.py", - "ba_data/python-site-packages/yaml/scanner.py", - "ba_data/python-site-packages/yaml/serializer.py", - "ba_data/python-site-packages/yaml/tokens.py", "ba_data/textures/achievementBoxer.dds", "ba_data/textures/achievementBoxer.ktx", "ba_data/textures/achievementBoxer.pvr", diff --git a/src/assets/Makefile b/src/assets/Makefile index c3bb8bb3..13318c00 100644 --- a/src/assets/Makefile +++ b/src/assets/Makefile @@ -2691,53 +2691,17 @@ $(foreach element,$(SCRIPT_TARGETS_PYC_PRIVATE_ANDROID),\ $(eval $(call make-opt-pyc-target,$(element)))) SCRIPT_TARGETS_PY_PRIVATE_COMMON = \ - $(BUILD_DIR)/ba_data/python-site-packages/_yaml/__init__.py \ $(BUILD_DIR)/ba_data/python-site-packages/certifi/__init__.py \ $(BUILD_DIR)/ba_data/python-site-packages/certifi/__main__.py \ $(BUILD_DIR)/ba_data/python-site-packages/certifi/core.py \ $(BUILD_DIR)/ba_data/python-site-packages/typing_extensions.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__init__.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/composer.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/constructor.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/cyaml.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/dumper.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/emitter.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/error.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/events.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/loader.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/nodes.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/parser.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/reader.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/representer.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/resolver.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/scanner.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/serializer.py \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/tokens.py \ $(BUILD_DIR)/sphinx/static/conf.py SCRIPT_TARGETS_PYC_PRIVATE_COMMON = \ - $(BUILD_DIR)/ba_data/python-site-packages/_yaml/__pycache__/__init__.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python-site-packages/certifi/__pycache__/__init__.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python-site-packages/certifi/__pycache__/__main__.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python-site-packages/certifi/__pycache__/core.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python-site-packages/__pycache__/typing_extensions.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/__init__.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/composer.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/constructor.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/cyaml.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/dumper.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/emitter.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/error.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/events.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/loader.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/nodes.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/parser.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/reader.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/representer.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/resolver.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/scanner.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/serializer.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python-site-packages/yaml/__pycache__/tokens.cpython-312.opt-1.pyc \ $(BUILD_DIR)/sphinx/static/__pycache__/conf.cpython-312.opt-1.pyc # Rule to copy src asset scripts to dst. diff --git a/src/assets/server_package/README.txt b/src/assets/server_package/README.txt index fe0c8d35..6d13ea08 100644 --- a/src/assets/server_package/README.txt +++ b/src/assets/server_package/README.txt @@ -2,8 +2,8 @@ To run this, simply cd into this directory and run ./ballisticakit_server (on mac or linux) or launch_ballisticakit_server.bat (on windows). You'll need to open a UDP port (43210 by default) so that the world can communicate with your server. -You can configure your server by editing the config.yaml file. -(if you only see config_template.yaml, you can copy/rename that to config.yaml) +You can configure your server by editing the config.toml file. +(if you only see config_template.toml, you can copy/rename that to config.toml) Platform-Specific Notes: diff --git a/src/assets/server_package/ballisticakit_server.py b/src/assets/server_package/ballisticakit_server.py index d43784cb..23884f01 100755 --- a/src/assets/server_package/ballisticakit_server.py +++ b/src/assets/server_package/ballisticakit_server.py @@ -39,6 +39,8 @@ VERSION_STR = '1.3.2' # # - Updated to use Python 3.12. # +# - Server config file is now in toml format instead of yaml. +# # 1.3.1 # # - Windows binary is now named 'BallisticaKitHeadless.exe'. @@ -101,7 +103,7 @@ class ServerManagerApp: IMMEDIATE_SHUTDOWN_TIME_LIMIT = 5.0 def __init__(self) -> None: - self._config_path = 'config.yaml' + self._config_path = 'config.toml' self._user_provided_config_path = False self._config = ServerConfig() self._ba_root_path = os.path.abspath('dist/ba_root') @@ -476,11 +478,9 @@ class ServerManagerApp: + cls._par( 'Set the config file read by the server script. The config' ' file contains most options for what kind of game to host.' - ' It should be in yaml format. Note that yaml is backwards' - ' compatible with json so you can just write json if you' - ' want to. If not specified, the script will look for a' - ' file named \'config.yaml\' in the same directory as the' - ' script.' + ' It should be in toml format. If not specified, the script' + ' will look for a file named \'config.toml\' in the same' + ' directory as the script.' ) + '\n' f'{Clr.BLD}--root [path]{Clr.RST}\n' @@ -594,23 +594,17 @@ class ServerManagerApp: # Don't be so lenient if the user pointed us at one though. raise RuntimeError(f"Config file not found: '{self._config_path}'.") - import yaml + import tomllib with open(self._config_path, encoding='utf-8') as infile: - user_config_raw = yaml.safe_load(infile.read()) + user_config_raw = tomllib.loads(infile.read()) - # An empty config file will yield None, and that's ok. - if user_config_raw is not None: - out = dataclass_from_dict(ServerConfig, user_config_raw) + out = dataclass_from_dict(ServerConfig, user_config_raw) # Update our known mod-time since we know it exists. self._config_mtime = Path(self._config_path).stat().st_mtime self._last_config_mtime_check_time = time.time() - # Go with defaults if we weren't able to load anything. - if out is None: - out = ServerConfig() - if print_confirmation: print( f'{Clr.CYN}Valid server config file loaded.{Clr.RST}', diff --git a/src/assets/server_package/config_template.yaml b/src/assets/server_package/config_template.toml similarity index 55% rename from src/assets/server_package/config_template.yaml rename to src/assets/server_package/config_template.toml index f2b38507..e0472c3e 100644 --- a/src/assets/server_package/config_template.yaml +++ b/src/assets/server_package/config_template.toml @@ -1,5 +1,5 @@ -# To configure your server, create a config.yaml file in the same directory -# as the ballisticakit_server script. The config_template.yaml file can be +# To configure your server, create a config.toml file in the same directory +# as the ballisticakit_server script. The config_template.toml file can be # copied or renamed as a convenient starting point. # Uncomment any of these values to override defaults. diff --git a/tools/batools/build.py b/tools/batools/build.py index 129b9e34..f0422e3c 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -446,92 +446,85 @@ def _get_server_config_raw_contents(projroot: str) -> str: return textwrap.dedent('\n'.join(lines[firstline : lastline + 1])) -def _get_server_config_template_yaml(projroot: str) -> str: - # pylint: disable=too-many-branches - # pylint: disable=too-many-statements - import yaml +def _get_server_config_template_toml(projroot: str) -> str: + from tomlkit import document, dumps + from bacommon.servermanager import ServerConfig + + cfg = ServerConfig() + + # Override some defaults with values we want to display commented + # out instead. + cfg.playlist_code = 12345 + cfg.stats_url = 'https://mystatssite.com/showstats?player=${ACCOUNT}' + cfg.clean_exit_minutes = 60 + cfg.unclean_exit_minutes = 90 + cfg.idle_exit_minutes = 20 + cfg.admins = ['pb-yOuRAccOuNtIdHErE', 'pb-aNdMayBeAnotherHeRE'] + cfg.protocol_version = 35 + cfg.session_max_players_override = 8 + cfg.playlist_inline = [] + cfg.team_names = ('Red', 'Blue') + cfg.team_colors = ((0.1, 0.25, 1.0), (1.0, 0.25, 0.2)) lines_in = _get_server_config_raw_contents(projroot).splitlines() + + # Convert to double quotes only (we'll convert back at the end). + assert all(('"' not in l) for l in lines_in) + lines_in = [l.replace("'", '"') for l in lines_in] + lines_out: list[str] = [] ignore_vars = {'stress_test_players'} for line in lines_in: - if any(line.startswith(f'{var}:') for var in ignore_vars): - continue - if line.startswith(' '): - # Ignore indented lines (our few multi-line special cases). - continue - if line.startswith(']') or line.startswith(')'): - # Ignore closing lines (our few multi-line special cases). - continue + # Replace attr declarations with commented out toml values. + if line != '' and not line.startswith('#') and ':' in line: + before_colon, _after_colon = line.split(':', 1) + vname = before_colon.strip() + if vname in ignore_vars: + continue + vval: Any = getattr(cfg, vname) - if line.startswith('team_names:'): - lines_out += [ - '#team_names:', - '#- Blue', - '#- Red', - ] - continue + doc = document() + # Toml doesn't support None/null + if vval is None: + raise RuntimeError( + f"ServerManager value '{vname}' has value None." + f' This is not allowed in toml;' + f' please provide a dummy value.' + ) + assert vval is not None + doc[vname] = vval + lines_out += ['#' + l for l in dumps(doc).strip().splitlines()] - if line.startswith('team_colors:'): - lines_out += [ - '#team_colors:', - '#- [0.1, 0.25, 1.0]', - '#- [1.0, 0.25, 0.2]', - ] - continue + # Preserve blank lines, but only one in a row. + elif line == '': + if not lines_out or lines_out[-1] != '': + lines_out.append(line) - if line.startswith('playlist_inline:'): - lines_out += ['#playlist_inline: []'] - continue - - if line != '' and not line.startswith('#'): - before_equal_sign, vval_raw = line.split('=', 1) - before_equal_sign = before_equal_sign.strip() - vval_raw = vval_raw.strip() - vname = before_equal_sign.split()[0] - assert vname.endswith(':'), f"'{vname}' does not end with ':'" - vname = vname[:-1] - vval: Any - if vval_raw == 'field(default_factory=list)': - vval = [] - else: - vval = eval(vval_raw) # pylint: disable=eval-used - - # Filter/override a few things. - if vname == 'playlist_code': - # User wouldn't want to pass the default of None here. - vval = 12345 - elif vname == 'clean_exit_minutes': - vval = 60 - elif vname == 'unclean_exit_minutes': - vval = 90 - elif vname == 'idle_exit_minutes': - vval = 20 - elif vname == 'stats_url': - vval = 'https://mystatssite.com/showstats?player=${ACCOUNT}' - elif vname == 'admins': - vval = ['pb-yOuRAccOuNtIdHErE', 'pb-aNdMayBeAnotherHeRE'] - elif vname == 'protocol_version': - vval = 35 - lines_out += [ - '#' + l for l in yaml.dump({vname: vval}).strip().splitlines() - ] - else: - # Convert comments referring to python bools to yaml bools. + # Preserve comment lines. + elif line.startswith('#'): + # Convert comments referring to python bools to toml bools. line = line.replace('True', 'true').replace('False', 'false') + if '(internal)' not in line: lines_out.append(line) - return '\n'.join(lines_out) + + out = '\n'.join(lines_out) + + # Convert back to single quotes only. + assert "'" not in out + out = out.replace('"', "'") + + return out -def filter_server_config(projroot: str, infilepath: str) -> str: +def filter_server_config_toml(projroot: str, infilepath: str) -> str: """Add commented-out config options to a server config.""" with open(infilepath, encoding='utf-8') as infile: cfg = infile.read() return cfg.replace( '# __CONFIG_TEMPLATE_VALUES__', - _get_server_config_template_yaml(projroot), + _get_server_config_template_toml(projroot), ) diff --git a/tools/batools/staging.py b/tools/batools/staging.py index 11d2a158..911e5794 100755 --- a/tools/batools/staging.py +++ b/tools/batools/staging.py @@ -669,8 +669,8 @@ class AssetStager: projroot=self.projroot, mode=modeval, infilename=f'{self.projroot}/src/assets/server_package/' - 'config_template.yaml', - outfilename=os.path.join(self.serverdst, 'config_template.yaml'), + 'config_template.toml', + outfilename=os.path.join(self.serverdst, 'config_template.toml'), ) if self.win_type is not None: fname = 'launch_ballisticakit_server.bat' @@ -763,11 +763,11 @@ def _stage_server_file( os.makedirs(os.path.dirname(outfilename), exist_ok=True) basename = os.path.basename(infilename) - if basename == 'config_template.yaml': + if basename == 'config_template.toml': # Inject all available config values into the config file. _write_if_changed( outfilename, - batools.build.filter_server_config(str(projroot), infilename), + batools.build.filter_server_config_toml(str(projroot), infilename), ) elif basename == 'ballisticakit_server.py': diff --git a/tools/efrotools/toolconfig.py b/tools/efrotools/toolconfig.py index 81f60546..01c13d07 100644 --- a/tools/efrotools/toolconfig.py +++ b/tools/efrotools/toolconfig.py @@ -23,7 +23,7 @@ def install_tool_config(projroot: Path, src: Path, dst: Path) -> None: """Install a config.""" print(f'Creating tool config: {Clr.BLD}{dst}{Clr.RST}') - # Special case: if we've got a src .yaml and a dst .json, convert. + # Special case: if we've got a src .toml and a dst .json, convert. # This can be handy to add annotations/etc. in the src which isn't # possible with json. if src.suffix == '.toml' and dst.suffix == '.json':