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
|
import configparser
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
#declare default vars
|
#declare default vars
|
||||||
version = 01.02
|
class Config():
|
||||||
|
|
||||||
|
|
||||||
|
AccountKey = "NK"
|
||||||
|
AccountID = "NA"
|
||||||
|
version = 01.02
|
||||||
|
|
||||||
|
|
||||||
#declare files
|
#declare files
|
||||||
@@ -12,33 +18,45 @@ 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():
|
||||||
config.read(configPath)
|
try:
|
||||||
version = config["DEFAULT"]["Version"]
|
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:
|
def showIntroText():
|
||||||
print("The file Config does not exist. - Creating")
|
print("Tiropit Launcher CLI - Release Branch")
|
||||||
makeConfig()
|
print(f"[TCLI]===========================[{Config.version}]")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Begin
|
||||||
|
|
||||||
print("Tiropit Launcher CLI - Release Branch")
|
checkConfig()
|
||||||
print(f"===========================[{version}]")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
showIntroText()
|
||||||
Reference in New Issue
Block a user