72 lines
1.6 KiB
Python
72 lines
1.6 KiB
Python
import configparser
|
|
import os
|
|
from pathlib import Path
|
|
|
|
#declare default vars
|
|
class Config():
|
|
|
|
|
|
AccountKey = "NK"
|
|
AccountID = "NA"
|
|
version = 01.02
|
|
|
|
|
|
#declare files
|
|
config = configparser.ConfigParser()
|
|
configPath = Path("Config.ini")
|
|
|
|
def WarnMissingConfig(ConfigError):
|
|
print(f"[⚠️ WARNING ⚠️] - Your config file is corrupt , something that has to do with {ConfigError}")
|
|
print("Program will exit before it crashes :)")
|
|
reset = input("It is recommended that you reset the app data (you will be logged out) y (reset) / n (exit)")
|
|
if reset == "y":
|
|
os.remove(configPath)
|
|
print("[⚠️ WARNING ⚠️] - Reset Done, Re-Open TiropitCLI")
|
|
exit(0)
|
|
|
|
|
|
def makeConfig():
|
|
config['DEFAULT'] = {'Version': Config.version}
|
|
config['ACCOUNT'] = {}
|
|
config['ACCOUNT']['KEY'] = "NK"
|
|
config['ACCOUNT']["ID"] = "NA"
|
|
|
|
with open('Config.ini', 'w') as configfile:
|
|
config.write(configfile)
|
|
|
|
|
|
def loadConfig():
|
|
try:
|
|
config.read(configPath)
|
|
Config.version = config["DEFAULT"]["Version"]
|
|
Config.AccountID = config["ACCOUNT"]["ID"]
|
|
Config.AccountID = config["ACCOUNT"]["KEY"]
|
|
except Exception as e:
|
|
WarnMissingConfig(e)
|
|
|
|
def checkConfig():
|
|
if configPath.exists():
|
|
print("The Config file exists.")
|
|
loadConfig()
|
|
|
|
else:
|
|
print("The file Config does not exist. - Creating")
|
|
makeConfig()
|
|
|
|
|
|
|
|
|
|
def showIntroText():
|
|
print("Tiropit Launcher CLI - Release Branch")
|
|
print(f"[TCLI]===========================[{Config.version}]")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Begin
|
|
|
|
checkConfig()
|
|
|
|
showIntroText() |