77 lines
2.2 KiB
Python
77 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
|
|
"""
|
|
ChaCha DoConfig script
|
|
"""
|
|
|
|
import argparse
|
|
from enum import Enum
|
|
from dataclasses import dataclass
|
|
#from configparser import ConfigParser
|
|
from configobj import ConfigObj
|
|
from collections import OrderedDict
|
|
from os.path import join
|
|
|
|
from pprint import pprint
|
|
from ChaChaSimpleINI import ChaChaSimpleINI
|
|
|
|
|
|
|
|
class OptionType(Enum):
|
|
OT_INVALID = 0
|
|
OT_STRING = 1
|
|
OT_INTEGER = 2
|
|
OT_BOOLEAN = 3
|
|
OT_FLOAT = 4
|
|
|
|
@dataclass
|
|
class Options:
|
|
szName:str = ""
|
|
szSectionName:str = ""
|
|
szKeyName:str = ""
|
|
TValueType:OptionType = OptionType.OT_INVALID
|
|
szDefaultValue:str = ""
|
|
szHelp:str = ""
|
|
|
|
OptionList = [
|
|
Options("Port", "URL", "Port", OptionType.OT_INTEGER, 7777, "Server Listening port")
|
|
]
|
|
|
|
def SetOption():
|
|
print("coucou")
|
|
|
|
def GetOption():
|
|
print("coucou2")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("-v", "--verbosity", action="count",
|
|
help="increase output verbosity")
|
|
|
|
parser.add_argument("-b", "--basegamedir",dest='basegamedir', action="store", required=True, help="set the game base dir")
|
|
parser.add_argument("-c", "--configfile",dest='configfile', action="store", help="set the default config file",default="UnrealTournament.ini")
|
|
|
|
subparsers = parser.add_subparsers(help='command type',dest='command',required=True)
|
|
SetOption_subparser = subparsers.add_parser("SetOption",help="Set/Add a game config file option value (may need reboot)")
|
|
|
|
GetOption_subparser = subparsers.add_parser("GetOption",help="Get a game config file option value")
|
|
|
|
args=parser.parse_args()
|
|
|
|
print("Using base game dir: {0}".format(args.basegamedir))
|
|
print("Using config file: {0}".format(args.configfile))
|
|
|
|
ConfigFilePath = join(args.basegamedir,"System",args.configfile)
|
|
|
|
inifile = ChaChaSimpleINI(ConfigFilePath)
|
|
|
|
|
|
|
|
if args.command == "SetOption":
|
|
SetOption()
|
|
elif args.command == "GetOption":
|
|
GetOption()
|
|
else:
|
|
raise RuntimeError("Invalid argument")
|