From 954c90b63cc9bde27d89eafde164f417f29d06a0 Mon Sep 17 00:00:00 2001 From: ClaytonWWilson Date: Fri, 13 Jul 2018 09:24:24 -0400 Subject: [PATCH] Added CTRL+C option to cancel login --- launcher.py | 7 +------ login.py | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/launcher.py b/launcher.py index b66af58..812ff84 100644 --- a/launcher.py +++ b/launcher.py @@ -37,14 +37,9 @@ while True: clearFolders() wait() elif choice == "3": # TODO if already logged in, ask 'are you sure?' - clear_screen() # TODO wait to clear login and add a ctrl+c option to cancel - # clearLogin() + clear_screen() login() wait() - # elif choice == "4": # TODO need to perform this option automatically - # clear_screen() - # refreshToken() - # wait() elif choice == "4": print("install requirements not implemented yet") wait() diff --git a/login.py b/login.py index 3b14388..7ccafec 100644 --- a/login.py +++ b/login.py @@ -27,14 +27,20 @@ def login(): tmp_user_key = "" tmp_user_name = "" - print("You can find your user key & request an API key while logged in at:\nhttps://www.thetvdb.com/?tab=userinfo\n") + print("You can find your user key & request an API key while logged in at:\n" + "https://www.thetvdb.com/?tab=userinfo\n" + "Press CTRL+C to cancel.\n") - while tmp_api_key is "": - tmp_api_key = input("Enter your api key: ") - while tmp_user_key is "": - tmp_user_key = input("Enter your user key: ") - while tmp_user_name is "": - tmp_user_name = input("Enter your username: ") + try: + while tmp_api_key is "": + tmp_api_key = input("Enter your api key: ") + while tmp_user_key is "": + tmp_user_key = input("Enter your user key: ") + while tmp_user_name is "": + tmp_user_name = input("Enter your username: ") + except KeyboardInterrupt as e: + print("\n") + return LOGIN_DATA = { "apikey": tmp_api_key,