Added ability for users to edit configuration during installation

This commit is contained in:
Pax1601
2023-11-20 18:19:41 +01:00
parent 31af3a53ce
commit 806d0cc52f
5 changed files with 529 additions and 15 deletions

View File

@@ -0,0 +1,4 @@
python -m venv venv
call ./venv/Scripts/activate
pip install pyinstaller
python -m PyInstaller configurator.py --onefile

View 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()

View 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,
)