mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added ability for users to edit configuration during installation
This commit is contained in:
4
scripts/python/build_configurator.bat
Normal file
4
scripts/python/build_configurator.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
python -m venv venv
|
||||
call ./venv/Scripts/activate
|
||||
pip install pyinstaller
|
||||
python -m PyInstaller configurator.py --onefile
|
||||
67
scripts/python/configurator.py
Normal file
67
scripts/python/configurator.py
Normal file
@@ -0,0 +1,67 @@
|
||||
import argparse, json
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='DCS Olympus configurator',
|
||||
description='This software allows to edit the DCS Olympus configuration file',
|
||||
epilog='')
|
||||
|
||||
parser.add_argument('-a', '--address')
|
||||
parser.add_argument('-c', '--clientPort')
|
||||
parser.add_argument('-b', '--backendPort')
|
||||
parser.add_argument('-p', '--password')
|
||||
parser.add_argument('-bp', '--bluePassword')
|
||||
parser.add_argument('-rp', '--redPassword')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open("olympus.json", "r") as fp:
|
||||
config = json.load(fp)
|
||||
|
||||
if (args.address is not None):
|
||||
config["server"]["address"] = args.address
|
||||
print(f"Address set to {args.address}")
|
||||
else:
|
||||
print("No address provided, skipping...")
|
||||
|
||||
if args.backendPort is not None:
|
||||
if args.backendPort.isdecimal():
|
||||
config["server"]["port"] = int(args.backendPort)
|
||||
print(f"Backend port set to {args.backendPort}")
|
||||
else:
|
||||
print(f"Invalid backend port provided {args.backendPort}")
|
||||
else:
|
||||
print("No backend port provided, skipping...")
|
||||
|
||||
if (args.password is not None):
|
||||
config["authentication"]["gameMasterPassword"] = args.password
|
||||
print(f"Game Master password set to {args.password}")
|
||||
else:
|
||||
print("No Game Master password provided, skipping...")
|
||||
|
||||
if (args.bluePassword is not None):
|
||||
config["authentication"]["blueCommanderPassword"] = args.bluePassword
|
||||
print(f"Blue Commander password set to {args.bluePassword}")
|
||||
else:
|
||||
print("No Blue Commander password provided, skipping...")
|
||||
|
||||
if (args.redPassword is not None):
|
||||
config["authentication"]["redCommanderPassword"] = args.redPassword
|
||||
print(f"Red Commander password set to {args.redPassword}")
|
||||
else:
|
||||
print("No Red Commander password provided, skipping...")
|
||||
|
||||
if args.clientPort is not None:
|
||||
if args.clientPort.isdecimal():
|
||||
config["client"]["port"] = int(args.clientPort)
|
||||
print(f"Client port set to {args.clientPort}")
|
||||
else:
|
||||
print(f"Invalid client port provided {args.clientPort}")
|
||||
else:
|
||||
print("No client port provided, skipping...")
|
||||
|
||||
with open("olympus.json", "w") as fp:
|
||||
json.dump(config, fp, indent = 4)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
44
scripts/python/configurator.spec
Normal file
44
scripts/python/configurator.spec
Normal file
@@ -0,0 +1,44 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(
|
||||
['configurator.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='configurator',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
Reference in New Issue
Block a user