mirror of
https://github.com/SinTan1729/TvTimeToTrakt.git
synced 2025-04-19 17:40:01 -05:00
Prompt config if it doesn't exist
This commit is contained in:
parent
5b31823c27
commit
01c683f78a
1 changed files with 23 additions and 20 deletions
|
@ -58,15 +58,24 @@ def isAuthenticated():
|
||||||
|
|
||||||
|
|
||||||
def getConfiguration() -> Config:
|
def getConfiguration() -> Config:
|
||||||
with open("config.json") as f:
|
try:
|
||||||
data = json.load(f)
|
with open("config.json") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
return Config(
|
return Config(
|
||||||
data["TRAKT_USERNAME"],
|
data["TRAKT_USERNAME"],
|
||||||
data["CLIENT_ID"],
|
data["CLIENT_ID"],
|
||||||
data["CLIENT_SECRET"],
|
data["CLIENT_SECRET"],
|
||||||
data["GDPR_WORKSPACE_PATH"],
|
data["GDPR_WORKSPACE_PATH"],
|
||||||
)
|
)
|
||||||
|
except FileNotFoundError:
|
||||||
|
logging.info("config.json not found prompting user for input")
|
||||||
|
return Config(
|
||||||
|
input("Enter your Trakt.tv username: "),
|
||||||
|
input("Enter you Client id: "),
|
||||||
|
input("Enter your Client secret: "),
|
||||||
|
input("Enter your GDPR workspace path: ")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
config = getConfiguration()
|
config = getConfiguration()
|
||||||
|
@ -817,18 +826,12 @@ def start():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Check that the user has created the config file
|
# Check that the user has provided the GDPR path
|
||||||
if os.path.exists("config.json"):
|
if os.path.isdir(config.gdpr_workspace_path):
|
||||||
# Check that the user has provided the GDPR path
|
start()
|
||||||
if os.path.isdir(config.gdpr_workspace_path):
|
|
||||||
start()
|
|
||||||
else:
|
|
||||||
logging.error(
|
|
||||||
"Oops! The TV Time GDPR folder '"
|
|
||||||
+ config.gdpr_workspace_path
|
|
||||||
+ "' does not exist on the local system. Please check it, and try again."
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
logging.error(
|
logging.error(
|
||||||
"The 'config.json' file cannot be found - have you created it yet?"
|
"Oops! The TV Time GDPR folder '"
|
||||||
|
+ config.gdpr_workspace_path
|
||||||
|
+ "' does not exist on the local system. Please check it, and try again."
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue