Config data update & failed config fetch exemption instead of crash

This commit is contained in:
2025-09-05 23:32:22 +03:00
parent 833e0ed2c8
commit 14728105d0

View File

@@ -1,7 +1,13 @@
import configparser import configparser
from pathlib import Path from pathlib import Path
#declare default vars #declare default vars
class Config():
AccountKey = "NK"
AccountID = "NA"
version = 01.02 version = 01.02
@@ -12,17 +18,23 @@ configPath = Path("Config.ini")
def makeConfig(): def makeConfig():
config['DEFAULT'] = {'Version': version} config['DEFAULT'] = {'Version': version}
config['ACCOUNT'] = {'KEY': "NK"}
config['ACCOUNT'] = {'ID': "NK"}
with open('Config.ini', 'w') as configfile: with open('Config.ini', 'w') as configfile:
config.write(configfile) config.write(configfile)
def loadConfig(): def loadConfig():
try:
config.read(configPath) config.read(configPath)
version = config["DEFAULT"]["Version"] Config.version = config["DEFAULT"]["Version"]
Config.AccountID = config["ACCOUNT"]["ID"]
Config.AccountID = config["ACCOUNT"]["KEY"]
except Exception as e:
print(f"An Error Occured , Check : {e}")
def checkConfig():
if configPath.exists(): if configPath.exists():
print("The Config file exists.") print("The Config file exists.")
loadConfig() loadConfig()
@@ -34,11 +46,17 @@ else:
def showIntroText():
print("Tiropit Launcher CLI - Release Branch") print("Tiropit Launcher CLI - Release Branch")
print(f"===========================[{version}]") print(f"[TCLI]===========================[{Config.version}]")
#Begin
checkConfig()
showIntroText()