Config data update & failed config fetch exemption instead of crash
This commit is contained in:
44
CLI/Init.py
44
CLI/Init.py
@@ -1,8 +1,14 @@
|
||||
import configparser
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
#declare default vars
|
||||
version = 01.02
|
||||
class Config():
|
||||
|
||||
|
||||
AccountKey = "NK"
|
||||
AccountID = "NA"
|
||||
version = 01.02
|
||||
|
||||
|
||||
#declare files
|
||||
@@ -12,33 +18,45 @@ configPath = Path("Config.ini")
|
||||
|
||||
def makeConfig():
|
||||
config['DEFAULT'] = {'Version': version}
|
||||
config['ACCOUNT'] = {'KEY': "NK"}
|
||||
config['ACCOUNT'] = {'ID': "NK"}
|
||||
|
||||
with open('Config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
|
||||
def loadConfig():
|
||||
config.read(configPath)
|
||||
version = config["DEFAULT"]["Version"]
|
||||
try:
|
||||
config.read(configPath)
|
||||
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():
|
||||
print("The Config file exists.")
|
||||
loadConfig()
|
||||
|
||||
else:
|
||||
print("The file Config does not exist. - Creating")
|
||||
makeConfig()
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
print("Tiropit Launcher CLI - Release Branch")
|
||||
print(f"===========================[{version}]")
|
||||
|
||||
|
||||
checkConfig()
|
||||
|
||||
showIntroText()
|
||||
Reference in New Issue
Block a user